Class InputDestination

java.lang.Object
org.springframework.cloud.stream.binder.test.InputDestination

public class InputDestination extends Object
Implementation of binder endpoint that represents the source destination (e.g., destination from which messages will be received by Processor.INPUT).
You can interact with it by calling send(Message) operation.
Author:
Oleg Zhurakousky
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    send(org.springframework.messaging.Message<?> message)
    Allows the Message to be sent to a Binder to be delegated to a default binding destination (e.g., "function-in-0" for cases where you only have a single function with the name 'function').
    void
    send(org.springframework.messaging.Message<?> message, String destinationName)
    Allows the Message to be sent to a Binder's destination.
    This needs a bit of clarification.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • InputDestination

      public InputDestination()
  • Method Details

    • send

      public void send(org.springframework.messaging.Message<?> message)
      Allows the Message to be sent to a Binder to be delegated to a default binding destination (e.g., "function-in-0" for cases where you only have a single function with the name 'function').
      Parameters:
      message - message to send
    • send

      public void send(org.springframework.messaging.Message<?> message, String destinationName)
      Allows the Message to be sent to a Binder's destination.
      This needs a bit of clarification. Just like with any binder, 'destination' name and 'binding' name are usually the same unless additional configuration is provided. For example; Assume you have a function 'uppercase'. The 'binding' names for this function would be 'uppercase-in-0' (for input) and 'uppercase-out-0' (for output). The 'destination' names would match as well unless you decide to provide something like 'spring.cloud.stream.bindings.uppercase-in-0.destination=upper' at which point the binding names and destination names are different.

      So, it is important to remember that since this binder's goal is to emulate real binders and real messaging systems you are sending TO and receiving FROM destination (as if it was real broker destination) and binder will map and delegate what you send to the binder's destination to individual bindings as would the real binder. *
      
      // assume the following properties
      "--spring.cloud.function.definition=uppercase",
      "--spring.cloud.stream.bindings.uppercase-in-0.destination=upper",
      "--spring.cloud.stream.bindings.uppercase-out-0.destination=upperout"
      
      // send/receive
      inputDestination.send(message, "upper");
      Message<byte[]> resultMessage = outputDestination.receive(1000, "upperout");
      
      // if 'destination' property is not provided for both input and output
      inputDestination.send(message, "uppercase-in-0");
      Message<byte[]> resultMessage = outputDestination.receive(1000, "uppercase-out-0");
      
      Parameters:
      message - message to send
      destinationName - the name of the destination