public class TestRabbitTemplate extends RabbitTemplate implements ApplicationContextAware, ApplicationListener<ContextRefreshedEvent>
RabbitTemplate
that invokes @RabbitListener
s directly.
It currently only supports the queue name in the routing key.
It does not currently support publisher confirms/returns.RabbitTemplate.ConfirmCallback, RabbitTemplate.ReturnCallback, RabbitTemplate.ReturnsCallback, RabbitTemplate.TemplateConsumer
RabbitOperations.OperationsCallback<T>
logger
Constructor and Description |
---|
TestRabbitTemplate(ConnectionFactory connectionFactory) |
Modifier and Type | Method and 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).
|
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, 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
afterPropertiesSet, convertRabbitAccessException, createConnection, getChannel, getConnection, getConnectionFactory, getTransactionalResourceHolder, isChannelTransacted, setChannelTransacted
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forPayload
convertSendAndReceiveAsType, getConnectionFactory, invoke
onMessageBatch
containerAckMode, onMessageBatch
public TestRabbitTemplate(ConnectionFactory connectionFactory)
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
setApplicationContext
in interface ApplicationContextAware
BeansException
public void onApplicationEvent(ContextRefreshedEvent event)
onApplicationEvent
in interface ApplicationListener<ContextRefreshedEvent>
protected boolean useDirectReplyTo()
RabbitTemplate
replyAddress
set and
useTemporaryReplyQueues
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.
useDirectReplyTo
in class RabbitTemplate
protected void sendToRabbit(com.rabbitmq.client.Channel channel, String exchange, String routingKey, boolean mandatory, Message message)
sendToRabbit
in class RabbitTemplate
protected Message doSendAndReceiveWithFixed(String exchange, String routingKey, Message message, CorrelationData correlationData)
doSendAndReceiveWithFixed
in class RabbitTemplate