Class AbstractMessageProducingHandler

All Implemented Interfaces:
org.reactivestreams.Subscriber<Message<?>>, Aware, BeanFactoryAware, BeanNameAware, DisposableBean, InitializingBean, ApplicationContextAware, Ordered, 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.
Author:
David Liu, Artem Bilan, Gary Russell, Marius Bogoevici since 4.1
  • Field Details Link icon

  • Constructor Details Link icon

    • AbstractMessageProducingHandler Link icon

      public AbstractMessageProducingHandler()
  • Method Details Link icon

    • setSendTimeout Link icon

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

      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 Link icon

      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 Link icon

      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 Link icon

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

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

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

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

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

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

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

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

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

      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 Link icon

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

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

      protected Object resolveErrorChannel(MessageHeaders requestHeaders)
    • setupMessageProcessor Link icon

      protected void setupMessageProcessor(MessageProcessor<?> processor)