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 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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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) Get the header patterns this handler doesn't propagate.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) final 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 void
setupMessageProcessor
(MessageProcessor<?> processor) protected boolean
Subclasses may override this.protected boolean
shouldSplitOutput
(Iterable<?> reply) protected final 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, setObservationConvention
Methods inherited from class org.springframework.integration.handler.MessageHandlerSupport
buildSendTimer, destroy, getComponentType, getIntegrationPatternType, getManagedName, getManagedType, getMetricsCaptor, getObservationRegistry, getOrder, getOverrides, isLoggingEnabled, isObserved, registerMetricsCaptor, registerObservationRegistry, 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, 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 reactor.core.CoreSubscriber
currentContext
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
-
messagingTemplate
-
-
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 aCompletableFuture
orPublisher
, send the output when it is satisfied rather than sending the future as the result. Ignored for return types other thanCompletableFuture
orPublisher
.- 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
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:
-
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:
-
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:
-
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
-
setupMessageProcessor
-