Class PublishSubscribeChannel
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.channel.AbstractMessageChannel
org.springframework.integration.channel.AbstractSubscribableChannel
org.springframework.integration.channel.AbstractExecutorChannel
org.springframework.integration.channel.PublishSubscribeChannel
- All Implemented Interfaces:
- Aware,- BeanFactoryAware,- BeanNameAware,- DisposableBean,- InitializingBean,- ApplicationContextAware,- BroadcastCapableChannel,- ExecutorChannelInterceptorAware,- ComponentSourceAware,- ExpressionCapable,- IntegrationPattern,- NamedComponent,- IntegrationManagement,- SubscribableChannelManagement,- TrackableComponent,- MessageChannel,- SubscribableChannel,- InterceptableChannel
public class PublishSubscribeChannel
extends AbstractExecutorChannel
implements BroadcastCapableChannel
A channel that sends Messages to each of its subscribers.
- Author:
- Mark Fisher, Oleg Zhurakousky, Gary Russell, Artem Bilan, Trung Pham
- 
Nested Class SummaryNested classes/interfaces inherited from class org.springframework.integration.channel.AbstractExecutorChannelAbstractExecutorChannel.MessageHandlingTaskNested classes/interfaces inherited from class org.springframework.integration.channel.AbstractMessageChannelAbstractMessageChannel.ChannelInterceptorListNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagementIntegrationManagement.ManagementOverrides
- 
Field SummaryFields inherited from class org.springframework.integration.channel.AbstractExecutorChanneldispatcher, executor, executorInterceptorsSize, maxSubscribersFields inherited from class org.springframework.integration.channel.AbstractMessageChannelinterceptors, metersFields 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.messaging.MessageChannelINDEFINITE_TIMEOUT
- 
Constructor SummaryConstructorsConstructorDescriptionCreate a PublishSubscribeChannel that will invoke the handlers in the message sender's thread.PublishSubscribeChannel(boolean requireSubscribers) Create a PublishSubscribeChannel that will invoke the handlers in the message sender's thread considering the providedrequireSubscribersflag.PublishSubscribeChannel(Executor executor) Create a PublishSubscribeChannel that will use anExecutorto invoke the handlers.PublishSubscribeChannel(Executor executor, boolean requireSubscribers) Create a PublishSubscribeChannel that will use anExecutorto invoke the handlers.
- 
Method SummaryModifier and TypeMethodDescriptionSubclasses may implement this method to provide component type information.protected BroadcastingDispatcherReturn a pattern type this component implements.final voidonInit()Callback method for initialization.voidsetApplySequence(boolean applySequence) Specify whether to apply the sequence number and size headers to the messages prior to invoking the subscribed handlers.voidsetErrorHandler(ErrorHandler errorHandler) Provide anErrorHandlerstrategy for handling Exceptions that occur downstream from this channel.voidsetIgnoreFailures(boolean ignoreFailures) Specify whether failures for one or more of the handlers should be ignored.voidsetMinSubscribers(int minSubscribers) If at least this number of subscribers receive the message,AbstractMessageChannel.send(org.springframework.messaging.Message)will return true.Methods inherited from class org.springframework.integration.channel.AbstractExecutorChanneladdInterceptor, addInterceptor, hasExecutorInterceptors, removeInterceptor, removeInterceptor, setInterceptors, setMaxSubscribersMethods inherited from class org.springframework.integration.channel.AbstractSubscribableChanneldoSend, getSubscriberCount, subscribe, unsubscribeMethods inherited from class org.springframework.integration.channel.AbstractMessageChanneldestroy, getFullChannelName, getIChannelInterceptorList, getInterceptors, getMetricsCaptor, getOverrides, isApplicationRunning, isLoggingEnabled, isObserved, registerMetricsCaptor, registerObservationRegistry, send, send, setDatatypes, setLoggingEnabled, setMessageConverter, setObservationConvention, setShouldTrackMethods inherited from class org.springframework.integration.context.IntegrationObjectSupportafterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentDescription, getComponentName, getComponentSource, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentDescription, setComponentName, setComponentSource, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.integration.channel.BroadcastCapableChannelisBroadcastMethods inherited from interface org.springframework.integration.support.management.IntegrationManagementgetManagedName, getManagedType, getThisAs, setManagedName, setManagedTypeMethods inherited from interface org.springframework.messaging.support.InterceptableChannelgetInterceptorsMethods inherited from interface org.springframework.messaging.MessageChannelsend, sendMethods inherited from interface org.springframework.integration.support.context.NamedComponentgetBeanName, getComponentNameMethods inherited from interface org.springframework.messaging.SubscribableChannelsubscribe, unsubscribe
- 
Constructor Details- 
PublishSubscribeChannelpublic PublishSubscribeChannel()Create a PublishSubscribeChannel that will invoke the handlers in the message sender's thread.
- 
PublishSubscribeChannelpublic PublishSubscribeChannel(boolean requireSubscribers) Create a PublishSubscribeChannel that will invoke the handlers in the message sender's thread considering the providedrequireSubscribersflag.- Parameters:
- requireSubscribers- if set to true, the sent message is considered as non-dispatched and rejected to the caller with the- "Dispatcher has no subscribers".
- Since:
- 5.4.3
 
- 
PublishSubscribeChannel
- 
PublishSubscribeChannelCreate a PublishSubscribeChannel that will use anExecutorto invoke the handlers. If this is null, each invocation will occur in the message sender's thread.- Parameters:
- executor- The executor.
- requireSubscribers- if set to true, the sent message is considered as non-dispatched and rejected to the caller with the- "Dispatcher has no subscribers".
- Since:
- 5.4.3
 
 
- 
- 
Method Details- 
getComponentTypeDescription copied from class:IntegrationObjectSupportSubclasses may implement this method to provide component type information.- Specified by:
- getComponentTypein interface- NamedComponent
- Overrides:
- getComponentTypein class- AbstractMessageChannel
 
- 
getIntegrationPatternTypeDescription copied from interface:IntegrationPatternReturn a pattern type this component implements.- Specified by:
- getIntegrationPatternTypein interface- IntegrationPattern
- Overrides:
- getIntegrationPatternTypein class- AbstractExecutorChannel
- Returns:
- the IntegrationPatternTypethis component implements.
 
- 
setErrorHandlerProvide anErrorHandlerstrategy for handling Exceptions that occur downstream from this channel. This will only be applied if an Executor has been configured to dispatch the Messages for this channel. Otherwise, Exceptions will be thrown directly within the sending Thread. If no ErrorHandler is provided, and this channel does delegate its dispatching to an Executor, the default strategy is aMessagePublishingErrorHandlerthat sends error messages to the failed request Message's error channel header if available or to the default 'errorChannel' otherwise.- Parameters:
- errorHandler- The error handler.
- See Also:
 
- 
setIgnoreFailurespublic void setIgnoreFailures(boolean ignoreFailures) Specify whether failures for one or more of the handlers should be ignored. By default, this is false meaning that an Exception will be thrown whenever a handler fails. To override this and suppress Exceptions, set the value to true.- Parameters:
- ignoreFailures- true if failures should be ignored.
 
- 
setApplySequencepublic void setApplySequence(boolean applySequence) Specify whether to apply the sequence number and size headers to the messages prior to invoking the subscribed handlers. By default, this value is false meaning that sequence headers will not be applied. If planning to use an Aggregator downstream with the default correlation and completion strategies, you should set this flag to true.- Parameters:
- applySequence- true if the sequence information should be applied.
 
- 
setMinSubscriberspublic void setMinSubscribers(int minSubscribers) If at least this number of subscribers receive the message,AbstractMessageChannel.send(org.springframework.messaging.Message)will return true. Default: 0.- Parameters:
- minSubscribers- The minimum number of subscribers.
 
- 
onInitpublic final void onInit()Callback method for initialization.- Overrides:
- onInitin class- AbstractMessageChannel
 
- 
getDispatcher- Specified by:
- getDispatcherin class- AbstractSubscribableChannel
 
 
-