Class TestRabbitTemplate
- java.lang.Object
-
- org.springframework.amqp.rabbit.connection.RabbitAccessor
-
- org.springframework.amqp.rabbit.core.RabbitTemplate
-
- org.springframework.amqp.rabbit.test.TestRabbitTemplate
-
- All Implemented Interfaces:
EventListener
,AmqpTemplate
,MessageListener
,PublisherCallbackChannel.Listener
,RabbitOperations
,ChannelAwareMessageListener
,ListenerContainerAware
,Aware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,ApplicationContextAware
,ApplicationListener<ContextRefreshedEvent>
,Lifecycle
public class TestRabbitTemplate extends RabbitTemplate implements ApplicationContextAware, ApplicationListener<ContextRefreshedEvent>
ARabbitTemplate
that invokes@RabbitListener
s directly. It currently only supports the queue name in the routing key. It does not currently support publisher confirms/returns.- Since:
- 2.0
- Author:
- Gary Russell, Artem Bilan
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.springframework.amqp.rabbit.core.RabbitTemplate
RabbitTemplate.ConfirmCallback, RabbitTemplate.ReturnCallback, RabbitTemplate.ReturnsCallback, RabbitTemplate.TemplateConsumer
-
Nested classes/interfaces inherited from interface org.springframework.amqp.rabbit.core.RabbitOperations
RabbitOperations.OperationsCallback<T>
-
-
Field Summary
-
Fields inherited from class org.springframework.amqp.rabbit.connection.RabbitAccessor
logger
-
-
Constructor Summary
Constructors Constructor Description TestRabbitTemplate(ConnectionFactory connectionFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Message
doSendAndReceiveWithFixed(String exchange, String routingKey, Message message, CorrelationData correlationData)
void
onApplicationEvent(ContextRefreshedEvent event)
protected void
sendToRabbit(com.rabbitmq.client.Channel channel, String exchange, String routingKey, boolean mandatory, Message message)
void
setApplicationContext(ApplicationContext applicationContext)
protected boolean
useDirectReplyTo()
Override this method use some other criteria to decide whether or not to use direct reply-to (https://www.rabbitmq.com/direct-reply-to.html).-
Methods inherited from class org.springframework.amqp.rabbit.core.RabbitTemplate
addAfterReceivePostProcessors, addBeforePublishPostProcessors, addListener, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertMessageIfNecessary, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveRaw, correlationConvertAndSend, destroy, determineConfirmsReturnsCapability, doReceiveNoWait, doSend, doSendAndReceive, doSendAndReceiveWithTemporary, doStart, doStop, execute, expectedQueueNames, getAfterReceivePostProcessors, getDefaultReceiveQueue, getEncoding, getExchange, getMessageConverter, getMessagePropertiesConverter, getRoutingKey, getUnconfirmed, getUnconfirmedCount, getUUID, handleConfirm, handleReturn, handleReturn, initDefaultStrategies, invoke, isChannelLocallyTransacted, isConfirmListener, isMandatoryFor, isReturnListener, isRunning, isUsePublisherConnection, nullSafeExchange, nullSafeRoutingKey, onMessage, onMessage, receive, receive, receive, receive, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndReply, receiveAndReply, receiveAndReply, receiveAndReply, receiveAndReply, receiveAndReply, removeAfterReceivePostProcessor, removeBeforePublishPostProcessor, replyTimedOut, revoke, send, send, send, send, send, sendAndReceive, sendAndReceive, sendAndReceive, sendAndReceive, sendAndReceive, sendAndReceive, setAfterReceivePostProcessors, setBeanFactory, setBeanName, setBeforePublishPostProcessors, setConfirmCallback, setConnectionFactory, setCorrelationDataPostProcessor, setCorrelationKey, setDefaultReceiveQueue, setEncoding, setExchange, setMandatory, setMandatoryExpression, setMandatoryExpressionString, setMessageConverter, setMessagePropertiesConverter, setNoLocalReplyConsumer, setReceiveConnectionFactorySelectorExpression, setReceiveTimeout, setRecoveryCallback, setReplyAddress, setReplyErrorHandler, setReplyTimeout, setRetryTemplate, setReturnCallback, setReturnsCallback, setRoutingKey, setSendConnectionFactorySelectorExpression, setTaskExecutor, setUseChannelForCorrelation, setUseDirectReplyToContainer, setUsePublisherConnection, setUserCorrelationId, setUserIdExpression, setUserIdExpressionString, setUseTemporaryReplyQueues, start, stop, waitForConfirms, waitForConfirmsOrDie
-
Methods inherited from class org.springframework.amqp.rabbit.connection.RabbitAccessor
afterPropertiesSet, convertRabbitAccessException, createConnection, getChannel, getConnection, getConnectionFactory, getTransactionalResourceHolder, isChannelTransacted, setChannelTransacted
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener
onMessageBatch
-
Methods inherited from interface org.springframework.amqp.core.MessageListener
containerAckMode, isAsyncReplies, onMessageBatch
-
Methods inherited from interface org.springframework.amqp.rabbit.core.RabbitOperations
convertSendAndReceiveAsType, getConnectionFactory, invoke
-
-
-
-
Constructor Detail
-
TestRabbitTemplate
public TestRabbitTemplate(ConnectionFactory connectionFactory)
-
-
Method Detail
-
setApplicationContext
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
- Specified by:
setApplicationContext
in interfaceApplicationContextAware
- Throws:
BeansException
-
onApplicationEvent
public void onApplicationEvent(ContextRefreshedEvent event)
- Specified by:
onApplicationEvent
in interfaceApplicationListener<ContextRefreshedEvent>
-
useDirectReplyTo
protected boolean useDirectReplyTo()
Description copied from class:RabbitTemplate
Override this method use some other criteria to decide whether or not to use direct reply-to (https://www.rabbitmq.com/direct-reply-to.html). The default implementation returns true if the broker supports it and there is noreplyAddress
set anduseTemporaryReplyQueues
is false. When direct reply-to is not used, the template will create a temporary, exclusive, auto-delete queue for the reply.This method is invoked once only - when the first message is sent, from a synchronized block.
- Overrides:
useDirectReplyTo
in classRabbitTemplate
- Returns:
- true to use direct reply-to.
-
sendToRabbit
protected void sendToRabbit(com.rabbitmq.client.Channel channel, String exchange, String routingKey, boolean mandatory, Message message)
- Overrides:
sendToRabbit
in classRabbitTemplate
-
doSendAndReceiveWithFixed
protected Message doSendAndReceiveWithFixed(String exchange, String routingKey, Message message, CorrelationData correlationData)
- Overrides:
doSendAndReceiveWithFixed
in classRabbitTemplate
-
-