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, Trung Pham, Christian Tzolov
-
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
messagingTemplateFields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSubclasses may implement this method to provide component type information.Return an unmodifiable list of handlers.Return a pattern type this component implements.protected voidhandleMessageInternal(Message<?> message) final booleanprotected voidonInit()Subclasses may implement this for initialization logic.voidsetHandlers(List<MessageHandler> handlers) protected booleanSubclasses may override this.final voidstart()final voidstop()final voidMethods inherited from class org.springframework.integration.handler.AbstractMessageProducingHandler
addNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, messageBuilderForReply, produceOutput, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, setSendTimeout, setupMessageProcessor, shouldSplitOutput, updateNotPropagatedHeadersMethods inherited from class org.springframework.integration.handler.AbstractMessageHandler
handleMessage, onComplete, onError, onNext, onSubscribe, setObservationConventionMethods inherited from class org.springframework.integration.handler.MessageHandlerSupport
buildSendTimer, destroy, getManagedName, getManagedType, getMetricsCaptor, getObservationRegistry, getOrder, getOverrides, isLoggingEnabled, isObserved, registerMetricsCaptor, registerObservationRegistry, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrackMethods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface reactor.core.CoreSubscriber
currentContextMethods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getThisAsMethods inherited from interface org.springframework.messaging.MessageHandler
handleMessageMethods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Constructor Details
-
MessageHandlerChain
public MessageHandlerChain()
-
-
Method Details
-
setHandlers
-
getHandlers
Description copied from interface:CompositeMessageHandlerReturn an unmodifiable list of handlers.- Specified by:
getHandlersin interfaceCompositeMessageHandler- Returns:
- the handlers.
-
getComponentType
Description copied from class:IntegrationObjectSupportSubclasses may implement this method to provide component type information.- Specified by:
getComponentTypein interfaceNamedComponent- Overrides:
getComponentTypein classMessageHandlerSupport
-
getIntegrationPatternType
Description copied from interface:IntegrationPatternReturn a pattern type this component implements.- Specified by:
getIntegrationPatternTypein interfaceIntegrationPattern- Overrides:
getIntegrationPatternTypein classMessageHandlerSupport- Returns:
- the
IntegrationPatternTypethis component implements.
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
onInitin classAbstractMessageProducingHandler
-
handleMessageInternal
- Specified by:
handleMessageInternalin classAbstractMessageHandler
-
shouldCopyRequestHeaders
protected boolean shouldCopyRequestHeaders()Description copied from class:AbstractMessageProducingHandlerSubclasses may override this. True by default.- Overrides:
shouldCopyRequestHeadersin classAbstractMessageProducingHandler- Returns:
- true if the request headers should be copied.
-
isRunning
public final boolean isRunning()- Specified by:
isRunningin interfaceLifecycle- Specified by:
isRunningin interfaceManageableLifecycle
-
start
public final void start()- Specified by:
startin interfaceLifecycle- Specified by:
startin interfaceManageableLifecycle
-
stop
public final void stop()- Specified by:
stopin interfaceLifecycle- Specified by:
stopin interfaceManageableLifecycle
-
stop
-