Class PublishSubscribeAmqpChannel
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.channel.AbstractMessageChannel
org.springframework.integration.amqp.channel.AbstractAmqpChannel
org.springframework.integration.amqp.channel.PublishSubscribeAmqpChannel
- All Implemented Interfaces:
ConnectionListener
,Aware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,ApplicationContextAware
,Lifecycle
,Phased
,SmartLifecycle
,BroadcastCapableChannel
,ExpressionCapable
,IntegrationPattern
,NamedComponent
,IntegrationManagement
,ManageableLifecycle
,ManageableSmartLifecycle
,TrackableComponent
,MessageChannel
,SubscribableChannel
,InterceptableChannel
public class PublishSubscribeAmqpChannel
extends AbstractAmqpChannel
implements BroadcastCapableChannel
The
AbstractSubscribableAmqpChannel
extension for pub-sub semantics based on the FanoutExchange
.- Since:
- 2.1
- Author:
- Mark Fisher, Gary Russell, Artem Bilan
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.integration.channel.AbstractMessageChannel
AbstractMessageChannel.ChannelInterceptorList
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides
-
Field Summary
Fields inherited from class org.springframework.integration.channel.AbstractMessageChannel
interceptors, meters
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger
Fields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
Fields inherited from interface org.springframework.messaging.MessageChannel
INDEFINITE_TIMEOUT
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
ConstructorDescriptionPublishSubscribeAmqpChannel
(String channelName, AbstractMessageListenerContainer container, AmqpTemplate amqpTemplate) Construct an instance with the supplied name, container and template; default header mappers will be used if the message is mapped.PublishSubscribeAmqpChannel
(String channelName, AbstractMessageListenerContainer container, AmqpTemplate amqpTemplate, AmqpHeaderMapper outboundMapper, AmqpHeaderMapper inboundMapper) Construct an instance with the supplied name, container and template; default header mappers will be used if the message is mapped. -
Method Summary
Modifier and TypeMethodDescriptionprotected AbstractDispatcher
void
destroy()
protected void
protected String
Subclasses may override this method to return an Exchange name.int
getPhase()
boolean
boolean
protected String
obtainQueueName
(String channelName) void
onInit()
Subclasses may implement this for initialization logic.void
setExchange
(FanoutExchange exchange) Configure the FanoutExchange instance.void
setMaxSubscribers
(int maxSubscribers) Specify the maximum number of subscribers supported by the channel's dispatcher (if it is anAbstractDispatcher
).void
start()
void
stop()
void
boolean
subscribe
(MessageHandler handler) boolean
unsubscribe
(MessageHandler handler) Methods inherited from class org.springframework.integration.amqp.channel.AbstractAmqpChannel
doSend, getAdmin, getAmqpTemplate, getConnectionFactory, getInboundHeaderMapper, getRabbitTemplate, getRoutingKey, isExtractPayload, isLoggingEnabled, onCreate, setAdmin, setConnectionFactory, setDefaultDeliveryMode, setExtractPayload, setHeadersMappedLast, setLoggingEnabled
Methods inherited from class org.springframework.integration.channel.AbstractMessageChannel
addInterceptor, addInterceptor, getComponentType, getFullChannelName, getIChannelInterceptorList, getIntegrationPatternType, getInterceptors, getMetricsCaptor, getOverrides, isObserved, registerMetricsCaptor, registerObservationRegistry, removeInterceptor, removeInterceptor, send, send, setDatatypes, setInterceptors, setMessageConverter, setObservationConvention, setShouldTrack
Methods 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, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.integration.channel.BroadcastCapableChannel
isBroadcast
Methods inherited from interface org.springframework.amqp.rabbit.connection.ConnectionListener
onClose, onFailed, onShutDown
Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getManagedName, getManagedType, getThisAs, setManagedName, setManagedType
Methods inherited from interface org.springframework.messaging.MessageChannel
send, send
Methods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
Methods inherited from interface org.springframework.messaging.SubscribableChannel
subscribe, unsubscribe
-
Constructor Details
-
PublishSubscribeAmqpChannel
public PublishSubscribeAmqpChannel(String channelName, AbstractMessageListenerContainer container, AmqpTemplate amqpTemplate) Construct an instance with the supplied name, container and template; default header mappers will be used if the message is mapped.- Parameters:
channelName
- the channel name.container
- the container.amqpTemplate
- the template.- See Also:
-
PublishSubscribeAmqpChannel
public PublishSubscribeAmqpChannel(String channelName, AbstractMessageListenerContainer container, AmqpTemplate amqpTemplate, AmqpHeaderMapper outboundMapper, AmqpHeaderMapper inboundMapper) Construct an instance with the supplied name, container and template; default header mappers will be used if the message is mapped.- Parameters:
channelName
- the channel name.container
- the container.amqpTemplate
- the templateoutboundMapper
- the outbound mapper.inboundMapper
- the inbound mapper.- Since:
- 4.3
- See Also:
-
-
Method Details
-
setExchange
Configure the FanoutExchange instance. If this is not provided, then a FanoutExchange will be declared implicitly, and its name will be the same as the channel name prefixed by "si.fanout.". In either case, an effectively anonymous Queue will be declared automatically.- Parameters:
exchange
- The fanout exchange.
-
getExchangeName
Description copied from class:AbstractAmqpChannel
Subclasses may override this method to return an Exchange name. By default, Messages will be sent to the no-name Direct Exchange.- Overrides:
getExchangeName
in classAbstractAmqpChannel
- Returns:
- The exchange name.
-
obtainQueueName
-
createDispatcher
-
doDeclares
protected void doDeclares()- Specified by:
doDeclares
in classAbstractAmqpChannel
-
setMaxSubscribers
public void setMaxSubscribers(int maxSubscribers) Specify the maximum number of subscribers supported by the channel's dispatcher (if it is anAbstractDispatcher
).- Parameters:
maxSubscribers
- The maximum number of subscribers allowed.
-
subscribe
- Specified by:
subscribe
in interfaceSubscribableChannel
-
unsubscribe
- Specified by:
unsubscribe
in interfaceSubscribableChannel
-
onInit
public void onInit()Description copied from class:IntegrationObjectSupport
Subclasses may implement this for initialization logic.- Overrides:
onInit
in classAbstractAmqpChannel
-
isAutoStartup
public boolean isAutoStartup()- Specified by:
isAutoStartup
in interfaceSmartLifecycle
-
getPhase
public int getPhase()- Specified by:
getPhase
in interfacePhased
- Specified by:
getPhase
in interfaceSmartLifecycle
-
isRunning
public boolean isRunning()- Specified by:
isRunning
in interfaceLifecycle
- Specified by:
isRunning
in interfaceManageableLifecycle
-
start
public void start()- Specified by:
start
in interfaceLifecycle
- Specified by:
start
in interfaceManageableLifecycle
-
stop
public void stop()- Specified by:
stop
in interfaceLifecycle
- Specified by:
stop
in interfaceManageableLifecycle
-
stop
- Specified by:
stop
in interfaceSmartLifecycle
-
destroy
public void destroy()- Specified by:
destroy
in interfaceDisposableBean
- Specified by:
destroy
in interfaceIntegrationManagement
- Overrides:
destroy
in classAbstractAmqpChannel
-