Class AbstractMessageSenderEndpoint

java.lang.Object
de.otto.synapse.endpoint.AbstractMessageEndpoint
de.otto.synapse.endpoint.sender.AbstractMessageSenderEndpoint
All Implemented Interfaces:
MessageEndpoint, MessageSenderEndpoint

public abstract class AbstractMessageSenderEndpoint
extends AbstractMessageEndpoint
implements MessageSenderEndpoint
Sender-side MessageEndpoint endpoint of a Message Channel with support for message translation. and interception.

Message Endpoint

See Also:
EIP: Message Endpoint, EIP: Message Channel
  • Constructor Details

    • AbstractMessageSenderEndpoint

      public AbstractMessageSenderEndpoint​(@Nonnull java.lang.String channelName, @Nonnull MessageInterceptorRegistry interceptorRegistry, @Nonnull MessageTranslator<TextMessage> messageTranslator)
      Constructor used to create a new MessageEndpoint.
      Parameters:
      channelName - the name of the underlying channel / stream / queue / message log.
      interceptorRegistry - registry used to determine message interceptors for this endpoint.
      messageTranslator - the MessageTranslator used to translate message payloads as expected by the consumers.
  • Method Details

    • send

      public final <T> java.util.concurrent.CompletableFuture<java.lang.Void> send​(@Nonnull Message<T> message)
      Sends a Message to the message channel.
      Specified by:
      send in interface MessageSenderEndpoint
      Type Parameters:
      T - type of the message's payload
      Parameters:
      message - the message to send
      Returns:
      a CompletableFuture that can be used for logging, error handling, waiting for completion, etc.
    • sendBatch

      public final <T> java.util.concurrent.CompletableFuture<java.lang.Void> sendBatch​(@Nonnull java.util.stream.Stream<Message<T>> batch)
      Sends a stream of messages to the message channel as one or more batches, if batches are supported by the infrastructure. If not, the messages are send one by one.
      Specified by:
      sendBatch in interface MessageSenderEndpoint
      Type Parameters:
      T - the type of the message payload
      Parameters:
      batch - a stream of messages that is sent in batched mode, if supported
      Returns:
      a CompletableFuture that can be used for logging, error handling, waiting for completion, etc.
    • getEndpointType

      @Nonnull public final 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
    • doSendBatch

      protected java.util.concurrent.CompletableFuture<java.lang.Void> doSendBatch​(@Nonnull java.util.stream.Stream<TextMessage> batch)
    • doSend

      protected abstract java.util.concurrent.CompletableFuture<java.lang.Void> doSend​(@Nonnull TextMessage message)