Class DelegateMessageQueueReceiverEndpoint

java.lang.Object
de.otto.synapse.endpoint.receiver.DelegateMessageQueueReceiverEndpoint
All Implemented Interfaces:
MessageEndpoint, MessageQueueReceiverEndpoint, MessageReceiverEndpoint

public class DelegateMessageQueueReceiverEndpoint
extends java.lang.Object
implements MessageQueueReceiverEndpoint
  • Constructor Details

    • DelegateMessageQueueReceiverEndpoint

      public DelegateMessageQueueReceiverEndpoint​(@Nonnull java.lang.String channelName, @Nonnull MessageQueueReceiverEndpointFactory messageQueueReceiverEndpointFactory)
  • Method Details

    • consume

      public java.util.concurrent.CompletableFuture<java.lang.Void> consume()
      Description copied from interface: MessageQueueReceiverEndpoint
      Takes zero or more messages from the channel, calls MessageEndpoint.intercept(TextMessage) for every message, and notifies the registered consumers with the intercepted message, or drops the message, if intercept returns null.

      Consumption starts with the earliest available and not-yet-consumed message and finishes when either the stopCondition is met, or the application is shutting down.

      The registered consumers are used as a callback for consumed messages. A MessageDispatcher can be used as a consumer, if multiple consumers, or consumers with message payloads other than String are required.

      Specified by:
      consume in interface MessageQueueReceiverEndpoint
      Returns:
      completable future that can be used to wait until the endpoint has stopped message consumption.
    • stop

      public void stop()
      Description copied from interface: MessageQueueReceiverEndpoint
      Stops consumption of messages and shuts down the MessageQueueReceiverEndpoint.
      Specified by:
      stop in interface MessageQueueReceiverEndpoint
    • register

      public void register​(MessageConsumer<?> messageConsumer)
      Description copied from interface: MessageReceiverEndpoint
      Registers a MessageConsumer at the receiver endpoint. consumers have to be thread safe as they might be called from multiple threads in parallel (e.g. for kinesis streams there is one thread per shard).
      Specified by:
      register in interface MessageReceiverEndpoint
      Parameters:
      messageConsumer - registered EventConsumer
    • getMessageDispatcher

      @Nonnull public MessageDispatcher getMessageDispatcher()
      Description copied from interface: MessageReceiverEndpoint
      Returns the MessageDispatcher that is used to dispatch messages.
      Specified by:
      getMessageDispatcher in interface MessageReceiverEndpoint
      Returns:
      MessageDispatcher
    • getChannelName

      @Nonnull public java.lang.String getChannelName()
      Description copied from interface: MessageEndpoint
      Returns the name of the channel.

      The channel name corresponds to the name of the underlying stream, queue or message log.

      Specified by:
      getChannelName in interface MessageEndpoint
      Returns:
      name of the channel
    • getInterceptorChain

      @Nonnull public InterceptorChain getInterceptorChain()
      Description copied from interface: MessageEndpoint
      Returns the InterceptorChain of the MessageEndpoint.
      Specified by:
      getInterceptorChain in interface MessageEndpoint
      Returns:
      InterceptorChain
    • getEndpointType

      @Nonnull public EndpointType getEndpointType()
      Description copied from interface: MessageEndpoint
      Returns the type of the MessageEndpoint, either EndpointType.SENDER or EndpointType.RECEIVER.
      Specified by:
      getEndpointType in interface MessageEndpoint
      Returns:
      EndpointType
    • intercept

      @Nullable public TextMessage intercept​(@Nonnull TextMessage message)
      Description copied from interface: MessageEndpoint
      Intercepts a message using all registered interceptors and returns the resulting message.

      The interceptors are called in order. The result of one interceptor is propagated to the next interceptor in the chain, until the end of the chain is reached, or one interceptor has returned null.

      If null is returned, the message must be dropped by the AbstractMessageEndpoint.

      Every interceptor may transform the message, or may take additional actions like, for example, logging, monitoring or other things.

      Specified by:
      intercept in interface MessageEndpoint
      Parameters:
      message - the message to intercept
      Returns:
      the (possibly modified) message, or null if the message should be dropped.