Class MessageHandlerChain
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.handler.MessageHandlerSupport
org.springframework.integration.handler.AbstractMessageHandler
org.springframework.integration.handler.AbstractMessageProducingHandler
org.springframework.integration.handler.MessageHandlerChain
- All Implemented Interfaces:
org.reactivestreams.Subscriber<Message<?>>
,Aware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,ApplicationContextAware
,Lifecycle
,Ordered
,ExpressionCapable
,Orderable
,MessageProducer
,CompositeMessageHandler
,HeaderPropagationAware
,IntegrationPattern
,NamedComponent
,IntegrationManagement
,ManageableLifecycle
,TrackableComponent
,MessageHandler
,reactor.core.CoreSubscriber<Message<?>>
public class MessageHandlerChain extends AbstractMessageProducingHandler implements CompositeMessageHandler, ManageableLifecycle
A composite
MessageHandler
implementation that invokes a chain of
MessageHandler instances in order.
Each of the handlers except for the last one must implement the
MessageProducer
interface. The last handler must also if
the chain itself has an output channel configured. No other assumptions
are made about the type of handler.
It is expected that each handler will produce reply messages and send them to
its output channel, although this is not enforced. It is possible to filter
messages in the middle of the chain, for example using a
MessageFilter
.
A MessageHandler
returning null will have the
same effect, although this option is less expressive.
This component can be used from the namespace to improve the readability of the configuration by removing channels that can be created implicitly.
<chain>
<filter ref="someFilter"/>
<bean class="SomeMessageHandlerImplementation"/>
<transformer ref="someTransformer"/>
<aggregator ... />
</chain>
- Author:
- Mark Fisher, Iwein Fuld, Gary Russell, Artem Bilan
-
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.handler.AbstractMessageProducingHandler
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 MessageHandlerChain()
-
Method Summary
Modifier and Type Method Description String
getComponentType()
Subclasses may implement this method to provide component type information.List<MessageHandler>
getHandlers()
Return an unmodifiable list of handlers.IntegrationPatternType
getIntegrationPatternType()
Return a pattern type this component implements.protected void
handleMessageInternal(Message<?> message)
boolean
isRunning()
SmartLifecycle implementation (delegates to thehandlers
)protected void
onInit()
Subclasses may implement this for initialization logic.void
setHandlers(List<MessageHandler> handlers)
protected boolean
shouldCopyRequestHeaders()
Subclasses may override this.void
start()
void
stop()
void
stop(Runnable callback)
Methods inherited from class org.springframework.integration.handler.AbstractMessageProducingHandler
addNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, messageBuilderForReply, produceOutput, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, setSendTimeout, shouldSplitOutput, updateNotPropagatedHeaders
Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler
handleMessage, onComplete, onError, onNext, onSubscribe
Methods inherited from class org.springframework.integration.handler.MessageHandlerSupport
buildSendTimer, destroy, 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
-
Constructor Details
-
MessageHandlerChain
public MessageHandlerChain()
-
-
Method Details
-
setHandlers
-
getHandlers
Description copied from interface:CompositeMessageHandler
Return an unmodifiable list of handlers.- Specified by:
getHandlers
in interfaceCompositeMessageHandler
- Returns:
- the handlers.
-
getComponentType
Description copied from class:IntegrationObjectSupport
Subclasses may implement this method to provide component type information.- Specified by:
getComponentType
in interfaceNamedComponent
- Overrides:
getComponentType
in classMessageHandlerSupport
-
getIntegrationPatternType
Description copied from interface:IntegrationPattern
Return a pattern type this component implements.- Specified by:
getIntegrationPatternType
in interfaceIntegrationPattern
- Overrides:
getIntegrationPatternType
in classMessageHandlerSupport
- Returns:
- the
IntegrationPatternType
this component implements.
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupport
Subclasses may implement this for initialization logic.- Overrides:
onInit
in classAbstractMessageProducingHandler
-
handleMessageInternal
- Specified by:
handleMessageInternal
in classAbstractMessageHandler
-
shouldCopyRequestHeaders
protected boolean shouldCopyRequestHeaders()Description copied from class:AbstractMessageProducingHandler
Subclasses may override this. True by default.- Overrides:
shouldCopyRequestHeaders
in classAbstractMessageProducingHandler
- Returns:
- true if the request headers should be copied.
-
isRunning
public final boolean isRunning()SmartLifecycle implementation (delegates to thehandlers
)- Specified by:
isRunning
in interfaceLifecycle
- Specified by:
isRunning
in interfaceManageableLifecycle
-
start
public final void start()- Specified by:
start
in interfaceLifecycle
- Specified by:
start
in interfaceManageableLifecycle
-
stop
public final void stop()- Specified by:
stop
in interfaceLifecycle
- Specified by:
stop
in interfaceManageableLifecycle
-
stop
-