Class BarrierMessageHandler
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.AbstractReplyProducingMessageHandler
org.springframework.integration.aggregator.BarrierMessageHandler
- All Implemented Interfaces:
- org.reactivestreams.Subscriber<Message<?>>,- Aware,- BeanClassLoaderAware,- BeanFactoryAware,- BeanNameAware,- DisposableBean,- InitializingBean,- ApplicationContextAware,- Ordered,- ExpressionCapable,- Orderable,- MessageProducer,- DiscardingMessageHandler,- HeaderPropagationAware,- MessageTriggerAction,- IntegrationPattern,- NamedComponent,- IntegrationManagement,- TrackableComponent,- MessageHandler,- reactor.core.CoreSubscriber<Message<?>>
public class BarrierMessageHandler
extends AbstractReplyProducingMessageHandler
implements MessageTriggerAction, DiscardingMessageHandler
A message handler that suspends the thread until a message with corresponding
 correlation is passed into the 
trigger method or
 the timeout occurs. Only one thread with a particular correlation (result of invoking
 the CorrelationStrategy) can be suspended at a time. If the inbound thread does
 not arrive before the trigger thread, the latter is suspended until it does, or the
 timeout occurs. Separate timeouts may be configured for request and trigger messages.
 
 The default CorrelationStrategy is a HeaderAttributeCorrelationStrategy.
 
 The default output processor is a DefaultAggregatingMessageGroupProcessor.
- Since:
- 4.2
- Author:
- Gary Russell, Artem Bilan, Michel Jung
- 
Nested Class SummaryNested classes/interfaces inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandlerAbstractReplyProducingMessageHandler.RequestHandlerNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagementIntegrationManagement.ManagementOverrides
- 
Field SummaryFields inherited from class org.springframework.integration.handler.AbstractMessageProducingHandlermessagingTemplateFields inherited from class org.springframework.integration.context.IntegrationObjectSupportEXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagementMETER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.core.OrderedHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
- 
Constructor SummaryConstructorsConstructorDescriptionBarrierMessageHandler(long timeout) Construct an instance with the provided timeout and default correlation and output strategies.BarrierMessageHandler(long requestTimeout, long triggerTimeout) Construct an instance with the provided timeouts and default correlation and output strategies.BarrierMessageHandler(long requestTimeout, long triggerTimeout, CorrelationStrategy correlationStrategy) Construct an instance with the provided timeout and correlation strategy, and default output processor.BarrierMessageHandler(long requestTimeout, long triggerTimeout, MessageGroupProcessor outputProcessor) Construct an instance with the provided timeout and output processor, and default correlation strategy.BarrierMessageHandler(long requestTimeout, long triggerTimeout, MessageGroupProcessor outputProcessor, CorrelationStrategy correlationStrategy) Construct an instance with the provided timeout and output processor, and default correlation strategy.BarrierMessageHandler(long timeout, CorrelationStrategy correlationStrategy) Construct an instance with the provided timeout and correlation strategy, and default output processor.BarrierMessageHandler(long timeout, MessageGroupProcessor outputProcessor) Construct an instance with the provided timeout and output processor, and default correlation strategy.BarrierMessageHandler(long timeout, MessageGroupProcessor outputProcessor, CorrelationStrategy correlationStrategy) Construct an instance with the provided timeout and output processor, and default correlation strategy.
- 
Method SummaryModifier and TypeMethodDescriptionprotected ObjectbuildResult(Object key, Message<?> requestMessage, Message<?> releaseMessage) Override to change the default mechanism by which the inbound and release messages are returned as a result.Subclasses may implement this method to provide component type information.Return the discard channel.Return a pattern type this component implements.protected ObjecthandleRequestMessage(Message<?> requestMessage) Subclasses must implement this method to handle the request Message.voidsetDiscardChannel(MessageChannel discardChannel) Set the channel to which late arriving trigger messages are sent.voidsetDiscardChannelName(String discardChannelName) Set the name of the channel to which late arriving trigger messages are sent.voidTake some action based on the message.Methods inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandlerdoInit, doInvokeAdvisedRequestHandler, getBeanClassLoader, getRequiresReply, handleMessageInternal, hasAdviceChain, onInit, setAdviceChain, setBeanClassLoader, setRequiresReplyMethods inherited from class org.springframework.integration.handler.AbstractMessageProducingHandleraddNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, messageBuilderForReply, produceOutput, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, setSendTimeout, setupMessageProcessor, shouldCopyRequestHeaders, shouldSplitOutput, updateNotPropagatedHeadersMethods inherited from class org.springframework.integration.handler.AbstractMessageHandlerhandleMessage, onComplete, onError, onNext, onSubscribe, setObservationConventionMethods inherited from class org.springframework.integration.handler.MessageHandlerSupportbuildSendTimer, 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.IntegrationObjectSupportafterPropertiesSet, 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.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface reactor.core.CoreSubscribercurrentContextMethods inherited from interface org.springframework.integration.support.management.IntegrationManagementgetThisAsMethods inherited from interface org.springframework.messaging.MessageHandlerhandleMessageMethods inherited from interface org.springframework.integration.support.context.NamedComponentgetBeanName, getComponentName
- 
Constructor Details- 
BarrierMessageHandlerpublic BarrierMessageHandler(long timeout) Construct an instance with the provided timeout and default correlation and output strategies.- Parameters:
- timeout- the timeout in milliseconds for both, request and trigger messages.
 
- 
BarrierMessageHandlerConstruct an instance with the provided timeout and output processor, and default correlation strategy.- Parameters:
- timeout- the timeout in milliseconds for both, request and trigger messages.
- outputProcessor- the output- MessageGroupProcessor.
 
- 
BarrierMessageHandlerConstruct an instance with the provided timeout and correlation strategy, and default output processor.- Parameters:
- timeout- the timeout in milliseconds for both, request and trigger messages.
- correlationStrategy- the correlation strategy.
 
- 
BarrierMessageHandlerpublic BarrierMessageHandler(long timeout, MessageGroupProcessor outputProcessor, CorrelationStrategy correlationStrategy) Construct an instance with the provided timeout and output processor, and default correlation strategy.- Parameters:
- timeout- the timeout in milliseconds for both, request and trigger messages.
- outputProcessor- the output- MessageGroupProcessor.
- correlationStrategy- the correlation strategy.
 
- 
BarrierMessageHandlerpublic BarrierMessageHandler(long requestTimeout, long triggerTimeout) Construct an instance with the provided timeouts and default correlation and output strategies.- Parameters:
- requestTimeout- the timeout in milliseconds when waiting for trigger message.
- triggerTimeout- the timeout in milliseconds when waiting for a request message.
- Since:
- 5.4
 
- 
BarrierMessageHandlerpublic BarrierMessageHandler(long requestTimeout, long triggerTimeout, MessageGroupProcessor outputProcessor) Construct an instance with the provided timeout and output processor, and default correlation strategy.- Parameters:
- requestTimeout- the timeout in milliseconds when waiting for trigger message.
- triggerTimeout- the timeout in milliseconds when waiting for a request message.
- outputProcessor- the output- MessageGroupProcessor.
- Since:
- 5.4
 
- 
BarrierMessageHandlerpublic BarrierMessageHandler(long requestTimeout, long triggerTimeout, CorrelationStrategy correlationStrategy) Construct an instance with the provided timeout and correlation strategy, and default output processor.- Parameters:
- requestTimeout- the timeout in milliseconds when waiting for trigger message.
- triggerTimeout- the timeout in milliseconds when waiting for a request message.
- correlationStrategy- the correlation strategy.
- Since:
- 5.4
 
- 
BarrierMessageHandlerpublic BarrierMessageHandler(long requestTimeout, long triggerTimeout, MessageGroupProcessor outputProcessor, CorrelationStrategy correlationStrategy) Construct an instance with the provided timeout and output processor, and default correlation strategy.- Parameters:
- requestTimeout- the timeout in milliseconds when waiting for trigger message.
- triggerTimeout- the timeout in milliseconds when waiting for a request message.
- outputProcessor- the output- MessageGroupProcessor.
- correlationStrategy- the correlation strategy.
- Since:
- 5.4
 
 
- 
- 
Method Details- 
setDiscardChannelNameSet the name of the channel to which late arriving trigger messages are sent.- Parameters:
- discardChannelName- the discard channel.
- Since:
- 5.0
 
- 
setDiscardChannelSet the channel to which late arriving trigger messages are sent.- Parameters:
- discardChannel- the discard channel.
- Since:
- 5.0
 
- 
getDiscardChannelDescription copied from interface:DiscardingMessageHandlerReturn the discard channel.- Specified by:
- getDiscardChannelin interface- DiscardingMessageHandler
- Returns:
- the channel.
- Since:
- 5.0
 
- 
getComponentTypeDescription copied from class:IntegrationObjectSupportSubclasses may implement this method to provide component type information.- Specified by:
- getComponentTypein interface- NamedComponent
- Overrides:
- getComponentTypein class- MessageHandlerSupport
 
- 
getIntegrationPatternTypeDescription copied from interface:IntegrationPatternReturn a pattern type this component implements.- Specified by:
- getIntegrationPatternTypein interface- IntegrationPattern
- Overrides:
- getIntegrationPatternTypein class- AbstractReplyProducingMessageHandler
- Returns:
- the IntegrationPatternTypethis component implements.
 
- 
handleRequestMessageDescription copied from class:AbstractReplyProducingMessageHandlerSubclasses must implement this method to handle the request Message. The return value may be a Message, a MessageBuilder, or any plain Object. The base class will handle the final creation of a reply Message from any of those starting points. If the return value is null, the Message flow will end here.- Specified by:
- handleRequestMessagein class- AbstractReplyProducingMessageHandler
- Parameters:
- requestMessage- The request message.
- Returns:
- The result of handling the message, or null.
 
- 
buildResultOverride to change the default mechanism by which the inbound and release messages are returned as a result.- Parameters:
- key- The correlation key.
- requestMessage- the inbound message.
- releaseMessage- the release message.
- Returns:
- the result.
 
- 
triggerDescription copied from interface:MessageTriggerActionTake some action based on the message.- Specified by:
- triggerin interface- MessageTriggerAction
- Parameters:
- message- the message.
 
 
-