Class PollableAmqpChannel
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.channel.AbstractMessageChannel
org.springframework.integration.amqp.channel.AbstractAmqpChannel
org.springframework.integration.amqp.channel.PollableAmqpChannel
- All Implemented Interfaces:
ConnectionListener
,Aware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,ApplicationContextAware
,ExecutorChannelInterceptorAware
,ExpressionCapable
,IntegrationPattern
,NamedComponent
,IntegrationManagement
,TrackableComponent
,MessageChannel
,PollableChannel
,InterceptableChannel
public class PollableAmqpChannel extends AbstractAmqpChannel implements PollableChannel, ExecutorChannelInterceptorAware
A
PollableChannel
implementation that is backed by an AMQP Queue.
Messages will be sent to the default (no-name) exchange with that Queue's
name as the routing key.- Since:
- 2.1
- Author:
- Mark Fisher, Artem Bilan, Gary Russell
-
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
-
Constructor Summary
Constructors Constructor Description PollableAmqpChannel(String channelName, AmqpTemplate amqpTemplate)
Construct an instance with the supplied name, template and default header mappers used if the template is aRabbitTemplate
and the message is mapped.PollableAmqpChannel(String channelName, AmqpTemplate amqpTemplate, AmqpHeaderMapper outboundMapper, AmqpHeaderMapper inboundMapper)
Construct an instance with the supplied name, template and header mappers. -
Method Summary
Modifier and Type Method Description void
addInterceptor(int index, ChannelInterceptor interceptor)
Add a channel interceptor to the specified index of the list.void
addInterceptor(ChannelInterceptor interceptor)
Add a channel interceptor to the end of the list.protected void
doDeclares()
protected Message<?>
doReceive(Long timeout)
protected String
getRoutingKey()
Subclasses may override this method to return a routing key.boolean
hasExecutorInterceptors()
protected void
onInit()
Subclasses may implement this for initialization logic.protected Object
performReceive(Long timeout)
Message<?>
receive()
Message<?>
receive(long timeout)
ChannelInterceptor
removeInterceptor(int index)
boolean
removeInterceptor(ChannelInterceptor interceptor)
void
setAmqpAdmin(AmqpAdmin amqpAdmin)
Provide an instance of AmqpAdmin for implicitly declaring Queues if the queueName is not provided.void
setInterceptors(List<ChannelInterceptor> interceptors)
Set the list of channel interceptors.void
setQueueName(String queueName)
Provide an explicitly configured queue name.Methods inherited from class org.springframework.integration.amqp.channel.AbstractAmqpChannel
destroy, doSend, getAdmin, getAmqpTemplate, getConnectionFactory, getExchangeName, getInboundHeaderMapper, getRabbitTemplate, isExtractPayload, isLoggingEnabled, onClose, onCreate, setAdmin, setConnectionFactory, setDefaultDeliveryMode, setExtractPayload, setHeadersMappedLast, setLoggingEnabled
Methods inherited from class org.springframework.integration.channel.AbstractMessageChannel
getComponentType, getFullChannelName, getIChannelInterceptorList, getIntegrationPatternType, getInterceptors, getMetricsCaptor, getOverrides, registerMetricsCaptor, send, send, setDatatypes, setMessageConverter, setShouldTrack
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, 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, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.amqp.rabbit.connection.ConnectionListener
onShutDown
Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getManagedName, getManagedType, getThisAs, setManagedName, setManagedType
Methods inherited from interface org.springframework.messaging.support.InterceptableChannel
getInterceptors
Methods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Constructor Details
-
PollableAmqpChannel
Construct an instance with the supplied name, template and default header mappers used if the template is aRabbitTemplate
and the message is mapped.- Parameters:
channelName
- the channel name.amqpTemplate
- the template.- See Also:
AbstractAmqpChannel.setExtractPayload(boolean)
-
PollableAmqpChannel
public PollableAmqpChannel(String channelName, AmqpTemplate amqpTemplate, AmqpHeaderMapper outboundMapper, AmqpHeaderMapper inboundMapper)Construct an instance with the supplied name, template and header mappers.- Parameters:
channelName
- the channel name.amqpTemplate
- the template.outboundMapper
- the outbound mapper.inboundMapper
- the inbound mapper.- Since:
- 4.3
- See Also:
AbstractAmqpChannel.setExtractPayload(boolean)
-
-
Method Details
-
setQueueName
Provide an explicitly configured queue name. If this is not provided, then a Queue will be created implicitly with the channelName as its name. The implicit creation will require that either an AmqpAdmin instance has been provided or that the configured AmqpTemplate is an instance of RabbitTemplate.- Parameters:
queueName
- The queue name.
-
setAmqpAdmin
Provide an instance of AmqpAdmin for implicitly declaring Queues if the queueName is not provided. When providing a RabbitTemplate implementation, this is not strictly necessary since a RabbitAdmin instance can be created from the template's ConnectionFactory reference.- Parameters:
amqpAdmin
- The amqp admin.
-
getRoutingKey
Description copied from class:AbstractAmqpChannel
Subclasses may override this method to return a routing key. By default, there will be no routing key (empty string).- Overrides:
getRoutingKey
in classAbstractAmqpChannel
- Returns:
- The routing key.
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupport
Subclasses may implement this for initialization logic.- Overrides:
onInit
in classAbstractAmqpChannel
-
doDeclares
protected void doDeclares()- Specified by:
doDeclares
in classAbstractAmqpChannel
-
receive
- Specified by:
receive
in interfacePollableChannel
-
receive
- Specified by:
receive
in interfacePollableChannel
-
doReceive
-
performReceive
-
setInterceptors
Description copied from class:AbstractMessageChannel
Set the list of channel interceptors. This will clear any existing interceptors.- Specified by:
setInterceptors
in interfaceInterceptableChannel
- Overrides:
setInterceptors
in classAbstractMessageChannel
- Parameters:
interceptors
- The list of interceptors.
-
addInterceptor
Description copied from class:AbstractMessageChannel
Add a channel interceptor to the end of the list.- Specified by:
addInterceptor
in interfaceInterceptableChannel
- Overrides:
addInterceptor
in classAbstractMessageChannel
- Parameters:
interceptor
- The interceptor.
-
addInterceptor
Description copied from class:AbstractMessageChannel
Add a channel interceptor to the specified index of the list.- Specified by:
addInterceptor
in interfaceInterceptableChannel
- Overrides:
addInterceptor
in classAbstractMessageChannel
- Parameters:
index
- The index to add interceptor.interceptor
- The interceptor.
-
removeInterceptor
- Specified by:
removeInterceptor
in interfaceInterceptableChannel
- Overrides:
removeInterceptor
in classAbstractMessageChannel
-
removeInterceptor
- Specified by:
removeInterceptor
in interfaceInterceptableChannel
- Overrides:
removeInterceptor
in classAbstractMessageChannel
-
hasExecutorInterceptors
public boolean hasExecutorInterceptors()- Specified by:
hasExecutorInterceptors
in interfaceExecutorChannelInterceptorAware
-