public class MessageHandlerChain extends AbstractMessageProducingHandler implements CompositeMessageHandler, 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>
IntegrationManagement.ManagementOverridesmessagingTemplateEXPRESSION_PARSER, loggerMETER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE| 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, updateNotPropagatedHeadershandleMessage, onComplete, onError, onNext, onSubscribebuildSendTimer, configureMetrics, destroy, getActiveCount, getActiveCountLong, getDuration, getErrorCount, getErrorCountLong, getHandleCount, getHandleCountLong, getHandlerMetrics, getManagedName, getManagedType, getMaxDuration, getMeanDuration, getMetricsCaptor, getMinDuration, getOrder, getOverrides, getStandardDeviationDuration, isCountsEnabled, isLoggingEnabled, isStatsEnabled, registerMetricsCaptor, reset, sendTimer, setCountsEnabled, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, setStatsEnabled, shouldTrackafterPropertiesSet, 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, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waithandleMessageerrorCount, handleCountgetBeanName, getComponentNamepublic void setHandlers(List<MessageHandler> handlers)
public List<MessageHandler> getHandlers()
CompositeMessageHandlergetHandlers in interface CompositeMessageHandlerpublic String getComponentType()
IntegrationObjectSupportgetComponentType in interface NamedComponentgetComponentType in class MessageHandlerSupportpublic IntegrationPatternType getIntegrationPatternType()
IntegrationPatterngetIntegrationPatternType in interface IntegrationPatterngetIntegrationPatternType in class MessageHandlerSupportIntegrationPatternType this component implements.protected void onInit()
IntegrationObjectSupportonInit in class AbstractMessageProducingHandlerprotected void handleMessageInternal(Message<?> message)
handleMessageInternal in class AbstractMessageHandlerprotected boolean shouldCopyRequestHeaders()
AbstractMessageProducingHandlershouldCopyRequestHeaders in class AbstractMessageProducingHandlerpublic final boolean isRunning()
handlers)public final void stop(Runnable callback)