public class MessageHandlerChain extends AbstractMessageHandler implements MessageProducer, org.springframework.context.Lifecycle
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>
logger| Constructor and Description |
|---|
MessageHandlerChain() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getComponentType()
Subclasses may implement this method to provide component type information.
|
protected void |
handleMessageInternal(org.springframework.messaging.Message<?> message) |
boolean |
isRunning()
SmartLifecycle implementation (delegates to the
handlers) |
protected void |
onInit()
Subclasses may implement this for initialization logic.
|
void |
setHandlers(java.util.List<org.springframework.messaging.MessageHandler> handlers) |
void |
setOutputChannel(org.springframework.messaging.MessageChannel outputChannel)
Specify the MessageChannel to which produced Messages should be sent.
|
void |
setSendTimeout(long sendTimeout) |
void |
start() |
void |
stop() |
void |
stop(java.lang.Runnable callback) |
getOrder, handleMessage, setOrder, setShouldTrackafterPropertiesSet, getApplicationContextId, getBeanFactory, getComponentName, getConversionService, getIntegrationProperties, getIntegrationProperty, getTaskScheduler, setApplicationContext, setBeanFactory, setBeanName, setComponentName, setConversionService, setTaskScheduler, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetComponentNamepublic void setHandlers(java.util.List<org.springframework.messaging.MessageHandler> handlers)
public void setOutputChannel(org.springframework.messaging.MessageChannel outputChannel)
MessageProducersetOutputChannel in interface MessageProducerpublic void setSendTimeout(long sendTimeout)
public java.lang.String getComponentType()
IntegrationObjectSupportgetComponentType in interface NamedComponentgetComponentType in class AbstractMessageHandlerprotected void onInit()
throws java.lang.Exception
IntegrationObjectSupportonInit in class IntegrationObjectSupportjava.lang.Exceptionprotected void handleMessageInternal(org.springframework.messaging.Message<?> message)
throws java.lang.Exception
handleMessageInternal in class AbstractMessageHandlerjava.lang.Exceptionpublic final boolean isRunning()
handlers)isRunning in interface org.springframework.context.Lifecyclepublic final void start()
start in interface org.springframework.context.Lifecyclepublic final void stop()
stop in interface org.springframework.context.Lifecyclepublic final void stop(java.lang.Runnable callback)