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(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<MessageHandler> handlers) |
void |
setOutputChannel(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, setShouldTrack
afterPropertiesSet, getApplicationContextId, getBeanFactory, getComponentName, getConversionService, getIntegrationProperties, getIntegrationProperty, getTaskScheduler, setApplicationContext, setBeanFactory, setBeanName, setComponentName, setConversionService, setTaskScheduler, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getComponentName
public void setHandlers(java.util.List<MessageHandler> handlers)
public void setOutputChannel(MessageChannel outputChannel)
MessageProducer
setOutputChannel
in interface MessageProducer
public void setSendTimeout(long sendTimeout)
public java.lang.String getComponentType()
IntegrationObjectSupport
getComponentType
in interface NamedComponent
getComponentType
in class AbstractMessageHandler
protected void onInit() throws java.lang.Exception
IntegrationObjectSupport
onInit
in class IntegrationObjectSupport
java.lang.Exception
protected void handleMessageInternal(Message<?> message) throws java.lang.Exception
handleMessageInternal
in class AbstractMessageHandler
java.lang.Exception
public final boolean isRunning()
handlers
)isRunning
in interface org.springframework.context.Lifecycle
public final void start()
start
in interface org.springframework.context.Lifecycle
public final void stop()
stop
in interface org.springframework.context.Lifecycle
public final void stop(java.lang.Runnable callback)