public class MessageHandlerChain extends AbstractMessageProducingHandler implements CompositeMessageHandler, ManageableLifecycle
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>
IntegrationManagement.ManagementOverrides
messagingTemplate
EXPRESSION_PARSER, logger
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
Constructor and Description |
---|
MessageHandlerChain() |
Modifier and Type | Method and 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 the
handlers ) |
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) |
addNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, messageBuilderForReply, produceOutput, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, setSendTimeout, shouldSplitOutput, updateNotPropagatedHeaders
handleMessage, onComplete, onError, onNext, onSubscribe
buildSendTimer, destroy, getManagedName, getManagedType, getMetricsCaptor, getOrder, getOverrides, isLoggingEnabled, registerMetricsCaptor, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrack
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
handleMessage
getThisAs
getBeanName, getComponentName
public void setHandlers(List<MessageHandler> handlers)
public List<MessageHandler> getHandlers()
CompositeMessageHandler
getHandlers
in interface CompositeMessageHandler
public String getComponentType()
IntegrationObjectSupport
getComponentType
in interface NamedComponent
getComponentType
in class MessageHandlerSupport
public IntegrationPatternType getIntegrationPatternType()
IntegrationPattern
getIntegrationPatternType
in interface IntegrationPattern
getIntegrationPatternType
in class MessageHandlerSupport
IntegrationPatternType
this component implements.protected void onInit()
IntegrationObjectSupport
onInit
in class AbstractMessageProducingHandler
protected void handleMessageInternal(Message<?> message)
handleMessageInternal
in class AbstractMessageHandler
protected boolean shouldCopyRequestHeaders()
AbstractMessageProducingHandler
shouldCopyRequestHeaders
in class AbstractMessageProducingHandler
public final boolean isRunning()
handlers
)isRunning
in interface Lifecycle
isRunning
in interface ManageableLifecycle
public final void start()
start
in interface Lifecycle
start
in interface ManageableLifecycle
public final void stop()
stop
in interface Lifecycle
stop
in interface ManageableLifecycle
public final void stop(Runnable callback)