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 MessagingTemplate
messagingTemplate
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger
Fields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
Constructors Constructor Description AbstractMessageProducingHandler()
-
Method Summary
Modifier and Type Method Description void
addNotPropagatedHeaders(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.MessageChannel
getOutputChannel()
Return the the output channel.protected boolean
isAsync()
protected AbstractIntegrationMessageBuilder<?>
messageBuilderForReply(Object reply)
protected void
onInit()
Subclasses may implement this for initialization logic.protected void
produceOutput(Object replyArg, Message<?> requestMessage)
protected Object
resolveErrorChannel(MessageHeaders requestHeaders)
protected void
sendErrorMessage(Message<?> requestMessage, Throwable ex)
protected void
sendOutput(Object output, Object replyChannelArg, boolean useArgChannel)
Send an output Message.protected void
sendOutputs(Object result, Message<?> requestMessage)
void
setAsync(boolean async)
Allow async replies.void
setNotPropagatedHeaders(String... headers)
Set header patterns ("xxx*", "*xxx", "*xxx*" or "xxx*yyy") that will NOT be copied from the inbound message ifshouldCopyRequestHeaaders
is true.void
setOutputChannel(MessageChannel outputChannel)
Specify theMessageChannel
to which produced Messages should be sent.void
setOutputChannelName(String outputChannelName)
Specify the bean name of theMessageChannel
to which produced Messages should be sent.void
setSendTimeout(long sendTimeout)
Set the timeout for sending reply Messages.protected boolean
shouldCopyRequestHeaders()
Subclasses may override this.protected boolean
shouldSplitOutput(Iterable<?> reply)
protected void
updateNotPropagatedHeaders(String[] headers, boolean merge)
Set or replace not propagated headers.Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler
handleMessage, handleMessageInternal, onComplete, onError, onNext, onSubscribe
Methods 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, shouldTrack
Methods 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, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getThisAs
Methods 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:MessageProducer
Specify theMessageChannel
to which produced Messages should be sent.- Specified by:
setOutputChannel
in interfaceMessageProducer
- Parameters:
outputChannel
- The output channel.
-
setOutputChannelName
Description copied from interface:MessageProducer
Specify the bean name of theMessageChannel
to which produced Messages should be sent.- Specified by:
setOutputChannelName
in 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 ifshouldCopyRequestHeaaders
is true. At least one pattern as "*" means do not copy headers at all.- Specified by:
setNotPropagatedHeaders
in 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:
getNotPropagatedHeaders
in interfaceHeaderPropagationAware
- Returns:
- an immutable
Collection
of 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:
addNotPropagatedHeaders
in 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:IntegrationObjectSupport
Subclasses may implement this for initialization logic.- Overrides:
onInit
in classIntegrationObjectSupport
-
getOutputChannel
Description copied from interface:MessageProducer
Return the the output channel.- Specified by:
getOutputChannel
in 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
-