Class AbstractMessageProducingHandler

All Implemented Interfaces:
org.reactivestreams.Subscriber<Message<?>>, Aware, BeanFactoryAware, BeanNameAware, DisposableBean, InitializingBean, ApplicationContextAware, Ordered, ComponentSourceAware, ExpressionCapable, Orderable, MessageProducer, HeaderPropagationAware, IntegrationPattern, NamedComponent, IntegrationManagement, TrackableComponent, MessageHandler, reactor.core.CoreSubscriber<Message<?>>
Direct Known Subclasses:
AbstractCorrelatingMessageHandler, AbstractReplyProducingMessageHandler, FluxAggregatorMessageHandler, MessageHandlerChain, MockMessageHandler

public abstract class AbstractMessageProducingHandler extends AbstractMessageHandler implements MessageProducer, HeaderPropagationAware
The base AbstractMessageHandler implementation for the MessageProducer.
Since:
4.1
Author:
David Liu, Artem Bilan, Gary Russell, Marius Bogoevici, Ngoc Nhan
  • Field Details

  • Constructor Details

    • AbstractMessageProducingHandler

      public AbstractMessageProducingHandler()
  • Method Details

    • setSendTimeout

      public void setSendTimeout(long sendTimeout)
      Set the timeout for sending reply Messages.
      Parameters:
      sendTimeout - The send timeout.
    • setOutputChannel

      public void setOutputChannel(MessageChannel outputChannel)
      Description copied from interface: MessageProducer
      Specify the MessageChannel to which produced Messages should be sent.
      Specified by:
      setOutputChannel in interface MessageProducer
      Parameters:
      outputChannel - The output channel.
    • setOutputChannelName

      public void setOutputChannelName(String outputChannelName)
      Description copied from interface: MessageProducer
      Specify the bean name of the MessageChannel to which produced Messages should be sent.
      Specified by:
      setOutputChannelName in interface MessageProducer
      Parameters:
      outputChannelName - The output channel bean name.
    • setAsync

      public final void setAsync(boolean async)
      Allow async replies. If the handler reply is a CompletableFuture or Publisher, send the output when it is satisfied rather than sending the future as the result. Ignored for return types other than CompletableFuture or Publisher.
      Parameters:
      async - true to allow.
      Since:
      4.3
    • isAsync

      protected boolean isAsync()
      Returns:
      true if this handler supports async replies.
      Since:
      4.3
      See Also:
    • setNotPropagatedHeaders

      public void setNotPropagatedHeaders(String... headers)
      Set header patterns ("xxx*", "*xxx", "*xxx*" or "xxx*yyy") that will NOT be copied from the inbound message if shouldCopyRequestHeaaders is true. At least one pattern as "*" means do not copy headers at all.
      Specified by:
      setNotPropagatedHeaders in interface HeaderPropagationAware
      Parameters:
      headers - the headers to not propagate from the inbound message.
      Since:
      4.3.10
      See Also:
    • updateNotPropagatedHeaders

      protected final void updateNotPropagatedHeaders(String[] headers, boolean merge)
      Set or replace not propagated headers. Exposed so that subclasses can set specific headers in a constructor, since setNotPropagatedHeaders(String...) is not final.
      Parameters:
      headers - Header patterns to not propagate.
      merge - true to merge with existing patterns; false to replace.
      Since:
      5.0.2
    • getNotPropagatedHeaders

      public Collection<String> getNotPropagatedHeaders()
      Get the header patterns this handler doesn't propagate.
      Specified by:
      getNotPropagatedHeaders in interface HeaderPropagationAware
      Returns:
      an immutable Collection of headers that will not be copied from the inbound message if shouldCopyRequestHeaders() is true.
      Since:
      4.3.10
      See Also:
    • addNotPropagatedHeaders

      public void addNotPropagatedHeaders(String... headers)
      Add header patterns ("xxx*", "*xxx", "*xxx*" or "xxx*yyy") that will NOT be copied from the inbound message if shouldCopyRequestHeaders() is true, instead of overwriting the existing set.
      Specified by:
      addNotPropagatedHeaders in interface HeaderPropagationAware
      Parameters:
      headers - the headers to not propagate from the inbound message.
      Since:
      4.3.10
      See Also:
    • onInit

      protected void onInit()
      Description copied from class: IntegrationObjectSupport
      Subclasses may implement this for initialization logic.
      Overrides:
      onInit in class IntegrationObjectSupport
    • getOutputChannel

      @Nullable public MessageChannel getOutputChannel()
      Description copied from interface: MessageProducer
      Return the output channel.
      Specified by:
      getOutputChannel in interface MessageProducer
      Returns:
      the channel.
    • sendOutputs

      protected void sendOutputs(Object result, Message<?> requestMessage)
    • shouldSplitOutput

      protected boolean shouldSplitOutput(Iterable<?> reply)
    • produceOutput

      protected void produceOutput(Object replyArg, Message<?> requestMessage)
    • messageBuilderForReply

      protected AbstractIntegrationMessageBuilder<?> messageBuilderForReply(Object reply)
    • createOutputMessage

      protected Message<?> createOutputMessage(Object output, MessageHeaders requestHeaders)
    • sendOutput

      protected void sendOutput(Object output, @Nullable Object replyChannelArg, boolean useArgChannel)
      Send an output Message. The 'replyChannel' will be considered only if this handler's 'outputChannel' is null. In that case, the 'replyChannel' value must not also be null, and it must be an instance of either String or MessageChannel.
      Parameters:
      output - the output object to send
      replyChannelArg - the 'replyChannel' value from the original request
      useArgChannel - use the replyChannel argument (must not be null), not the configured output channel.
    • shouldCopyRequestHeaders

      protected boolean shouldCopyRequestHeaders()
      Subclasses may override this. True by default.
      Returns:
      true if the request headers should be copied.
    • sendErrorMessage

      protected void sendErrorMessage(Message<?> requestMessage, Throwable ex)
    • resolveErrorChannel

      protected Object resolveErrorChannel(MessageHeaders requestHeaders)
    • setupMessageProcessor

      protected void setupMessageProcessor(MessageProcessor<?> processor)