Interface RabbitOperations
- All Superinterfaces:
AmqpTemplate
,Lifecycle
- All Known Implementing Classes:
BatchingRabbitTemplate
,RabbitTemplate
,TestRabbitTemplate
Rabbit specific methods for Amqp functionality.
- Author:
- Mark Pollack, Mark Fisher, Gary Russell, Artem Bilan
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
Callback for using the same channel for multiple RabbitTemplate operations. -
Method Summary
Modifier and TypeMethodDescriptionvoid
convertAndSend
(@Nullable String exchange, @Nullable String routingKey, Object message, MessagePostProcessor messagePostProcessor, @Nullable CorrelationData correlationData) Convert a Java object to an AmqpMessage
and send it to a specific exchange with a specific routing key.void
convertAndSend
(@Nullable String exchange, @Nullable String routingKey, Object message, @Nullable CorrelationData correlationData) Convert a Java object to an AmqpMessage
and send it to a specific exchange with a specific routing key.void
convertAndSend
(@Nullable String routingKey, Object message, MessagePostProcessor messagePostProcessor, @Nullable CorrelationData correlationData) Convert a Java object to an AmqpMessage
and send it to a default exchange with a specific routing key.void
convertAndSend
(@Nullable String routingKey, Object message, @Nullable CorrelationData correlationData) Convert a Java object to an AmqpMessage
and send it to a default exchange with a specific routing key.void
convertAndSend
(Object message, MessagePostProcessor messagePostProcessor, @Nullable CorrelationData correlationData) Convert a Java object to an AmqpMessage
and send it to a default exchange with a default routing key.@Nullable Object
convertSendAndReceive
(@Nullable String exchange, @Nullable String routingKey, Object message, @Nullable MessagePostProcessor messagePostProcessor, @Nullable CorrelationData correlationData) Basic RPC pattern with conversion.@Nullable Object
convertSendAndReceive
(@Nullable String exchange, @Nullable String routingKey, Object message, @Nullable CorrelationData correlationData) Basic RPC pattern with conversion.@Nullable Object
convertSendAndReceive
(@Nullable String routingKey, Object message, MessagePostProcessor messagePostProcessor, @Nullable CorrelationData correlationData) Basic RPC pattern with conversion.@Nullable Object
convertSendAndReceive
(@Nullable String routingKey, Object message, @Nullable CorrelationData correlationData) Basic RPC pattern with conversion.@Nullable Object
convertSendAndReceive
(Object message, MessagePostProcessor messagePostProcessor, @Nullable CorrelationData correlationData) Basic RPC pattern with conversion.@Nullable Object
convertSendAndReceive
(Object message, @Nullable CorrelationData correlationData) Basic RPC pattern with conversion.<T> @Nullable T
convertSendAndReceiveAsType
(@Nullable String exchange, @Nullable String routingKey, Object message, @Nullable MessagePostProcessor messagePostProcessor, @Nullable CorrelationData correlationData, ParameterizedTypeReference<T> responseType) Basic RPC pattern with conversion.default <T> @Nullable T
convertSendAndReceiveAsType
(@Nullable String exchange, @Nullable String routingKey, Object message, @Nullable CorrelationData correlationData, ParameterizedTypeReference<T> responseType) Basic RPC pattern with conversion.<T> @Nullable T
convertSendAndReceiveAsType
(@Nullable String routingKey, Object message, @Nullable MessagePostProcessor messagePostProcessor, @Nullable CorrelationData correlationData, ParameterizedTypeReference<T> responseType) Basic RPC pattern with conversion.<T> @Nullable T
convertSendAndReceiveAsType
(@Nullable String routingKey, Object message, @Nullable CorrelationData correlationData, ParameterizedTypeReference<T> responseType) Basic RPC pattern with conversion.<T> @Nullable T
convertSendAndReceiveAsType
(Object message, @Nullable MessagePostProcessor messagePostProcessor, @Nullable CorrelationData correlationData, ParameterizedTypeReference<T> responseType) Basic RPC pattern with conversion.<T> @Nullable T
convertSendAndReceiveAsType
(Object message, @Nullable CorrelationData correlationData, ParameterizedTypeReference<T> responseType) Basic RPC pattern with conversion.void
correlationConvertAndSend
(Object message, CorrelationData correlationData) Convert a Java object to an AmqpMessage
and send it to a default exchange with a default routing key.<T> @Nullable T
execute
(ChannelCallback<? extends @Nullable T> action) Execute the callback with a channel and reliably close the channel afterward.Return the connection factory for these operations.default <T> @Nullable T
invoke
(RabbitOperations.OperationsCallback<? extends @Nullable T> action) Invoke the callback and run all operations on the template argument in a dedicated thread-bound channel and reliably close the channel afterward.<T> @Nullable T
invoke
(RabbitOperations.OperationsCallback<? extends @Nullable T> action, @Nullable com.rabbitmq.client.ConfirmCallback acks, @Nullable com.rabbitmq.client.ConfirmCallback nacks) Invoke operations on the same channel.default boolean
void
send
(@Nullable String exchange, @Nullable String routingKey, Message message, @Nullable CorrelationData correlationData) Send a message to a specific exchange with a specific routing key.default void
send
(@Nullable String routingKey, Message message, @Nullable CorrelationData correlationData) Send a message to the default exchange with a specific routing key.default void
start()
default void
stop()
boolean
waitForConfirms
(long timeout) Delegate to the underlying dedicated channel to wait for confirms.void
waitForConfirmsOrDie
(long timeout) Delegate to the underlying dedicated channel to wait for confirms.Methods inherited from interface org.springframework.amqp.core.AmqpTemplate
convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertAndSend, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceive, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveAsType, convertSendAndReceiveAsType, receive, receive, receive, receive, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndConvert, receiveAndReply, receiveAndReply, receiveAndReply, receiveAndReply, receiveAndReply, receiveAndReply, send, send, send, sendAndReceive, sendAndReceive, sendAndReceive
-
Method Details
-
execute
Execute the callback with a channel and reliably close the channel afterward.- Type Parameters:
T
- the return type.- Parameters:
action
- the call back.- Returns:
- the result from the
ChannelCallback.doInRabbit(com.rabbitmq.client.Channel)
. - Throws:
AmqpException
- if one occurs.
-
invoke
default <T> @Nullable T invoke(RabbitOperations.OperationsCallback<? extends @Nullable T> action) throws AmqpException Invoke the callback and run all operations on the template argument in a dedicated thread-bound channel and reliably close the channel afterward.- Type Parameters:
T
- the return type.- Parameters:
action
- the call back.- Returns:
- the result from the
RabbitOperations.OperationsCallback.doInRabbit(RabbitOperations operations)
. - Throws:
AmqpException
- if one occurs.- Since:
- 2.0
-
invoke
<T> @Nullable T invoke(RabbitOperations.OperationsCallback<? extends @Nullable T> action, @Nullable com.rabbitmq.client.ConfirmCallback acks, @Nullable com.rabbitmq.client.ConfirmCallback nacks) Invoke operations on the same channel. If callbacks are needed, both callbacks must be supplied.- Type Parameters:
T
- the return type.- Parameters:
action
- the callback.acks
- a confirm callback for acks.nacks
- a confirm callback for nacks.- Returns:
- the result of the action method.
- Since:
- 2.1
-
waitForConfirms
Delegate to the underlying dedicated channel to wait for confirms. The connection factory must be configured for publisher confirms and this method must be called within the scope of aninvoke(OperationsCallback)
operation. RequiresCachingConnectionFactory#setPublisherConfirms(true)
.- Parameters:
timeout
- the timeout- Returns:
- true if acks and no nacks are received.
- Throws:
AmqpException
- if one occurs.- Since:
- 2.0
- See Also:
-
waitForConfirmsOrDie
Delegate to the underlying dedicated channel to wait for confirms. The connection factory must be configured for publisher confirms and this method must be called within the scope of aninvoke(OperationsCallback)
operation. RequiresCachingConnectionFactory#setPublisherConfirms(true)
.- Parameters:
timeout
- the timeout- Throws:
AmqpException
- if one occurs.- Since:
- 2.0
- See Also:
-
getConnectionFactory
ConnectionFactory getConnectionFactory()Return the connection factory for these operations.- Returns:
- the connection factory.
- Since:
- 2.0
-
send
default void send(@Nullable String routingKey, Message message, @Nullable CorrelationData correlationData) throws AmqpException Send a message to the default exchange with a specific routing key.- Parameters:
routingKey
- the routing keymessage
- a message to sendcorrelationData
- data to correlate publisher confirms.- Throws:
AmqpException
- if there is a problem- Since:
- 2.3
-
send
void send(@Nullable String exchange, @Nullable String routingKey, Message message, @Nullable CorrelationData correlationData) throws AmqpException Send a message to a specific exchange with a specific routing key.- Parameters:
exchange
- the name of the exchangeroutingKey
- the routing keymessage
- a message to sendcorrelationData
- data to correlate publisher confirms.- Throws:
AmqpException
- if there is a problem
-
correlationConvertAndSend
void correlationConvertAndSend(Object message, CorrelationData correlationData) throws AmqpException Convert a Java object to an AmqpMessage
and send it to a default exchange with a default routing key.- Parameters:
message
- a message to sendcorrelationData
- data to correlate publisher confirms.- Throws:
AmqpException
- if there is a problem
-
convertAndSend
void convertAndSend(@Nullable String routingKey, Object message, @Nullable CorrelationData correlationData) throws AmqpException Convert a Java object to an AmqpMessage
and send it to a default exchange with a specific routing key.- Parameters:
routingKey
- the routing keymessage
- a message to sendcorrelationData
- data to correlate publisher confirms.- Throws:
AmqpException
- if there is a problem
-
convertAndSend
void convertAndSend(@Nullable String exchange, @Nullable String routingKey, Object message, @Nullable CorrelationData correlationData) throws AmqpException Convert a Java object to an AmqpMessage
and send it to a specific exchange with a specific routing key.- Parameters:
exchange
- the name of the exchangeroutingKey
- the routing keymessage
- a message to sendcorrelationData
- data to correlate publisher confirms.- Throws:
AmqpException
- if there is a problem
-
convertAndSend
void convertAndSend(Object message, MessagePostProcessor messagePostProcessor, @Nullable CorrelationData correlationData) throws AmqpException Convert a Java object to an AmqpMessage
and send it to a default exchange with a default routing key.- Parameters:
message
- a message to sendmessagePostProcessor
- a processor to apply to the message before it is sentcorrelationData
- data to correlate publisher confirms.- Throws:
AmqpException
- if there is a problem
-
convertAndSend
void convertAndSend(@Nullable String routingKey, Object message, MessagePostProcessor messagePostProcessor, @Nullable CorrelationData correlationData) throws AmqpException Convert a Java object to an AmqpMessage
and send it to a default exchange with a specific routing key.- Parameters:
routingKey
- the routing keymessage
- a message to sendmessagePostProcessor
- a processor to apply to the message before it is sentcorrelationData
- data to correlate publisher confirms.- Throws:
AmqpException
- if there is a problem
-
convertAndSend
void convertAndSend(@Nullable String exchange, @Nullable String routingKey, Object message, MessagePostProcessor messagePostProcessor, @Nullable CorrelationData correlationData) throws AmqpException Convert a Java object to an AmqpMessage
and send it to a specific exchange with a specific routing key.- Parameters:
exchange
- the name of the exchangeroutingKey
- the routing keymessage
- a message to sendmessagePostProcessor
- a processor to apply to the message before it is sentcorrelationData
- data to correlate publisher confirms.- Throws:
AmqpException
- if there is a problem
-
convertSendAndReceive
@Nullable Object convertSendAndReceive(Object message, @Nullable CorrelationData correlationData) throws AmqpException Basic RPC pattern with conversion. Send a Java object converted to a message to a default exchange with a default routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout.- Parameters:
message
- a message to send.correlationData
- data to correlate publisher confirms.- Returns:
- the response if there is one
- Throws:
AmqpException
- if there is a problem
-
convertSendAndReceive
@Nullable Object convertSendAndReceive(@Nullable String routingKey, Object message, @Nullable CorrelationData correlationData) throws AmqpException Basic RPC pattern with conversion. Send a Java object converted to a message to a default exchange with a specific routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout.- Parameters:
routingKey
- the routing keymessage
- a message to sendcorrelationData
- data to correlate publisher confirms.- Returns:
- the response if there is one
- Throws:
AmqpException
- if there is a problem
-
convertSendAndReceive
@Nullable Object convertSendAndReceive(@Nullable String exchange, @Nullable String routingKey, Object message, @Nullable CorrelationData correlationData) throws AmqpException Basic RPC pattern with conversion. Send a Java object converted to a message to a specific exchange with a specific routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout.- Parameters:
exchange
- the name of the exchangeroutingKey
- the routing keymessage
- a message to sendcorrelationData
- data to correlate publisher confirms.- Returns:
- the response if there is one
- Throws:
AmqpException
- if there is a problem
-
convertSendAndReceive
@Nullable Object convertSendAndReceive(Object message, MessagePostProcessor messagePostProcessor, @Nullable CorrelationData correlationData) throws AmqpException Basic RPC pattern with conversion. Send a Java object converted to a message to a default exchange with a default routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout.- Parameters:
message
- a message to sendmessagePostProcessor
- a processor to apply to the message before it is sentcorrelationData
- data to correlate publisher confirms.- Returns:
- the response if there is one
- Throws:
AmqpException
- if there is a problem
-
convertSendAndReceive
@Nullable Object convertSendAndReceive(@Nullable String routingKey, Object message, MessagePostProcessor messagePostProcessor, @Nullable CorrelationData correlationData) throws AmqpException Basic RPC pattern with conversion. Send a Java object converted to a message to a default exchange with a specific routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout.- Parameters:
routingKey
- the routing keymessage
- a message to sendmessagePostProcessor
- a processor to apply to the message before it is sentcorrelationData
- data to correlate publisher confirms.- Returns:
- the response if there is one
- Throws:
AmqpException
- if there is a problem
-
convertSendAndReceive
@Nullable Object convertSendAndReceive(@Nullable String exchange, @Nullable String routingKey, Object message, @Nullable MessagePostProcessor messagePostProcessor, @Nullable CorrelationData correlationData) throws AmqpException Basic RPC pattern with conversion. Send a Java object converted to a message to a specific exchange with a specific routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout.- Parameters:
exchange
- the name of the exchangeroutingKey
- the routing keymessage
- a message to sendmessagePostProcessor
- a processor to apply to the message before it is sentcorrelationData
- data to correlate publisher confirms.- Returns:
- the response if there is one
- Throws:
AmqpException
- if there is a problem
-
convertSendAndReceiveAsType
<T> @Nullable T convertSendAndReceiveAsType(Object message, @Nullable CorrelationData correlationData, ParameterizedTypeReference<T> responseType) throws AmqpException Basic RPC pattern with conversion. Send a Java object converted to a message to a default exchange with a default routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout. Requires aSmartMessageConverter
.- Type Parameters:
T
- the type.- Parameters:
message
- a message to send.correlationData
- data to correlate publisher confirms.responseType
- the type to convert the reply to.- Returns:
- the response if there is one.
- Throws:
AmqpException
- if there is a problem.
-
convertSendAndReceiveAsType
<T> @Nullable T convertSendAndReceiveAsType(@Nullable String routingKey, Object message, @Nullable CorrelationData correlationData, ParameterizedTypeReference<T> responseType) throws AmqpException Basic RPC pattern with conversion. Send a Java object converted to a message to a default exchange with a specific routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout. Requires aSmartMessageConverter
.- Type Parameters:
T
- the type.- Parameters:
routingKey
- the routing keymessage
- a message to sendcorrelationData
- data to correlate publisher confirms.responseType
- the type to convert the reply to.- Returns:
- the response if there is one
- Throws:
AmqpException
- if there is a problem
-
convertSendAndReceiveAsType
default <T> @Nullable T convertSendAndReceiveAsType(@Nullable String exchange, @Nullable String routingKey, Object message, @Nullable CorrelationData correlationData, ParameterizedTypeReference<T> responseType) throws AmqpException Basic RPC pattern with conversion. Send a Java object converted to a message to a specific exchange with a specific routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout. Requires aSmartMessageConverter
.- Type Parameters:
T
- the type.- Parameters:
exchange
- the name of the exchangeroutingKey
- the routing keymessage
- a message to sendcorrelationData
- data to correlate publisher confirms.responseType
- the type to convert the reply to.- Returns:
- the response if there is one
- Throws:
AmqpException
- if there is a problem
-
convertSendAndReceiveAsType
<T> @Nullable T convertSendAndReceiveAsType(Object message, @Nullable MessagePostProcessor messagePostProcessor, @Nullable CorrelationData correlationData, ParameterizedTypeReference<T> responseType) throws AmqpException Basic RPC pattern with conversion. Send a Java object converted to a message to a default exchange with a default routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout. Requires aSmartMessageConverter
.- Type Parameters:
T
- the type.- Parameters:
message
- a message to sendmessagePostProcessor
- a processor to apply to the message before it is sentcorrelationData
- data to correlate publisher confirms.responseType
- the type to convert the reply to.- Returns:
- the response if there is one
- Throws:
AmqpException
- if there is a problem
-
convertSendAndReceiveAsType
<T> @Nullable T convertSendAndReceiveAsType(@Nullable String routingKey, Object message, @Nullable MessagePostProcessor messagePostProcessor, @Nullable CorrelationData correlationData, ParameterizedTypeReference<T> responseType) throws AmqpException Basic RPC pattern with conversion. Send a Java object converted to a message to a default exchange with a specific routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout. Requires aSmartMessageConverter
.- Type Parameters:
T
- the type.- Parameters:
routingKey
- the routing keymessage
- a message to sendmessagePostProcessor
- a processor to apply to the message before it is sentcorrelationData
- data to correlate publisher confirms.responseType
- the type to convert the reply to.- Returns:
- the response if there is one
- Throws:
AmqpException
- if there is a problem
-
convertSendAndReceiveAsType
<T> @Nullable T convertSendAndReceiveAsType(@Nullable String exchange, @Nullable String routingKey, Object message, @Nullable MessagePostProcessor messagePostProcessor, @Nullable CorrelationData correlationData, ParameterizedTypeReference<T> responseType) throws AmqpException Basic RPC pattern with conversion. Send a Java object converted to a message to a specific exchange with a specific routing key and attempt to receive a response, converting that to a Java object. Implementations will normally set the reply-to header to an exclusive queue and wait up for some time limited by a timeout. Requires aSmartMessageConverter
.- Type Parameters:
T
- the type.- Parameters:
exchange
- the name of the exchangeroutingKey
- the routing keymessage
- a message to sendmessagePostProcessor
- a processor to apply to the message before it is sentcorrelationData
- data to correlate publisher confirms.responseType
- the type to convert the reply to.- Returns:
- the response if there is one
- Throws:
AmqpException
- if there is a problem
-
start
-
stop
-
isRunning
-