Class AbstractMessageProducingHandler
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.handler.MessageHandlerSupport
org.springframework.integration.handler.AbstractMessageHandler
org.springframework.integration.handler.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
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides -
Field Summary
Fields Modifier and Type Field Description protected MessagingTemplatemessagingTemplateFields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors Constructor Description AbstractMessageProducingHandler() -
Method Summary
Modifier and Type Method Description voidaddNotPropagatedHeaders(String... headers)Add header patterns ("xxx*", "*xxx", "*xxx*" or "xxx*yyy") that will NOT be copied from the inbound message ifshouldCopyRequestHeaders()is true, instead of overwriting the existing set.protected Message<?>createOutputMessage(Object output, MessageHeaders requestHeaders)Collection<String>getNotPropagatedHeaders()Get the header patterns this handler doesn't propagate.MessageChannelgetOutputChannel()Return the the output channel.protected booleanisAsync()protected AbstractIntegrationMessageBuilder<?>messageBuilderForReply(Object reply)protected voidonInit()Subclasses may implement this for initialization logic.protected voidproduceOutput(Object replyArg, Message<?> requestMessage)protected ObjectresolveErrorChannel(MessageHeaders requestHeaders)protected voidsendErrorMessage(Message<?> requestMessage, Throwable ex)protected voidsendOutput(Object output, Object replyChannelArg, boolean useArgChannel)Send an output Message.protected voidsendOutputs(Object result, Message<?> requestMessage)voidsetAsync(boolean async)Allow async replies.voidsetNotPropagatedHeaders(String... headers)Set header patterns ("xxx*", "*xxx", "*xxx*" or "xxx*yyy") that will NOT be copied from the inbound message ifshouldCopyRequestHeaadersis true.voidsetOutputChannel(MessageChannel outputChannel)Specify theMessageChannelto which produced Messages should be sent.voidsetOutputChannelName(String outputChannelName)Specify the bean name of theMessageChannelto which produced Messages should be sent.voidsetSendTimeout(long sendTimeout)Set the timeout for sending reply Messages.protected booleanshouldCopyRequestHeaders()Subclasses may override this.protected booleanshouldSplitOutput(Iterable<?> reply)protected voidupdateNotPropagatedHeaders(String[] headers, boolean merge)Set or replace not propagated headers.Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler
handleMessage, handleMessageInternal, onComplete, onError, onNext, onSubscribeMethods inherited from class org.springframework.integration.handler.MessageHandlerSupport
buildSendTimer, destroy, getComponentType, getIntegrationPatternType, getManagedName, getManagedType, getMetricsCaptor, getOrder, getOverrides, isLoggingEnabled, registerMetricsCaptor, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrackMethods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getThisAsMethods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
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
Description copied from interface:MessageProducerSpecify theMessageChannelto which produced Messages should be sent.- Specified by:
setOutputChannelin interfaceMessageProducer- Parameters:
outputChannel- The output channel.
-
setOutputChannelName
Description copied from interface:MessageProducerSpecify the bean name of theMessageChannelto which produced Messages should be sent.- Specified by:
setOutputChannelNamein interfaceMessageProducer- Parameters:
outputChannelName- The output channel bean name.
-
setAsync
public final void setAsync(boolean async)Allow async replies. If the handler reply is aListenableFuture, send the output when it is satisfied rather than sending the future as the result. Ignored for return types other thanListenableFuture.- 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:
setAsync(boolean)
-
setNotPropagatedHeaders
Set header patterns ("xxx*", "*xxx", "*xxx*" or "xxx*yyy") that will NOT be copied from the inbound message ifshouldCopyRequestHeaadersis true. At least one pattern as "*" means do not copy headers at all.- Specified by:
setNotPropagatedHeadersin interfaceHeaderPropagationAware- Parameters:
headers- the headers to not propagate from the inbound message.- Since:
- 4.3.10
- See Also:
PatternMatchUtils
-
updateNotPropagatedHeaders
Set or replace not propagated headers. Exposed so that subclasses can set specific headers in a constructor, sincesetNotPropagatedHeaders(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
Get the header patterns this handler doesn't propagate.- Specified by:
getNotPropagatedHeadersin interfaceHeaderPropagationAware- Returns:
- an immutable
Collectionof headers that will not be copied from the inbound message ifshouldCopyRequestHeaders()is true. - Since:
- 4.3.10
- See Also:
setNotPropagatedHeaders(String...),PatternMatchUtils
-
addNotPropagatedHeaders
Add header patterns ("xxx*", "*xxx", "*xxx*" or "xxx*yyy") that will NOT be copied from the inbound message ifshouldCopyRequestHeaders()is true, instead of overwriting the existing set.- Specified by:
addNotPropagatedHeadersin interfaceHeaderPropagationAware- Parameters:
headers- the headers to not propagate from the inbound message.- Since:
- 4.3.10
- See Also:
setNotPropagatedHeaders(String...)
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
onInitin classIntegrationObjectSupport
-
getOutputChannel
Description copied from interface:MessageProducerReturn the the output channel.- Specified by:
getOutputChannelin interfaceMessageProducer- Returns:
- the channel.
-
sendOutputs
-
shouldSplitOutput
-
produceOutput
-
messageBuilderForReply
-
createOutputMessage
-
sendOutput
Send an output Message. The 'replyChannel' will be considered only if this handler's 'outputChannel' isnull. In that case, the 'replyChannel' value must not also benull, and it must be an instance of either String orMessageChannel.- Parameters:
output- the output object to sendreplyChannelArg- the 'replyChannel' value from the original requestuseArgChannel- - 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
-
resolveErrorChannel
-