public interface AmqpTemplate
convertAndSend(Object)
and
receiveAndConvert()
methods allow let you send and receive POJO objects.
Implementations are expected to delegate to an instance of
MessageConverter
to perform
conversion to and from AMQP byte[] payload type.Modifier and Type | Method and Description |
---|---|
void |
convertAndSend(Object message)
Convert a Java object to an Amqp
Message and send it to a default exchange
with a default routing key. |
void |
convertAndSend(Object message,
MessagePostProcessor messagePostProcessor)
Convert a Java object to an Amqp
Message and send it to a default exchange
with a default routing key. |
void |
convertAndSend(String routingKey,
Object message)
Convert a Java object to an Amqp
Message and send it to a default exchange
with a specific routing key. |
void |
convertAndSend(String routingKey,
Object message,
MessagePostProcessor messagePostProcessor)
Convert a Java object to an Amqp
Message and send it to a default exchange
with a specific routing key. |
void |
convertAndSend(String exchange,
String routingKey,
Object message)
Convert a Java object to an Amqp
Message and send it to a specific exchange
with a specific routing key. |
void |
convertAndSend(String exchange,
String routingKey,
Object message,
MessagePostProcessor messagePostProcessor)
Convert a Java object to an Amqp
Message and send it to a specific exchange
with a specific routing key. |
Object |
convertSendAndReceive(Object message)
Basic RPC pattern with conversion.
|
Object |
convertSendAndReceive(Object message,
MessagePostProcessor messagePostProcessor)
Basic RPC pattern with conversion.
|
Object |
convertSendAndReceive(String routingKey,
Object message)
Basic RPC pattern with conversion.
|
Object |
convertSendAndReceive(String routingKey,
Object message,
MessagePostProcessor messagePostProcessor)
Basic RPC pattern with conversion.
|
Object |
convertSendAndReceive(String exchange,
String routingKey,
Object message)
Basic RPC pattern with conversion.
|
Object |
convertSendAndReceive(String exchange,
String routingKey,
Object message,
MessagePostProcessor messagePostProcessor)
Basic RPC pattern with conversion.
|
<T> T |
convertSendAndReceiveAsType(Object message,
MessagePostProcessor messagePostProcessor,
ParameterizedTypeReference<T> responseType)
Basic RPC pattern with conversion.
|
<T> T |
convertSendAndReceiveAsType(Object message,
ParameterizedTypeReference<T> responseType)
Basic RPC pattern with conversion.
|
<T> T |
convertSendAndReceiveAsType(String routingKey,
Object message,
MessagePostProcessor messagePostProcessor,
ParameterizedTypeReference<T> responseType)
Basic RPC pattern with conversion.
|
<T> T |
convertSendAndReceiveAsType(String routingKey,
Object message,
ParameterizedTypeReference<T> responseType)
Basic RPC pattern with conversion.
|
<T> T |
convertSendAndReceiveAsType(String exchange,
String routingKey,
Object message,
MessagePostProcessor messagePostProcessor,
ParameterizedTypeReference<T> responseType)
Basic RPC pattern with conversion.
|
<T> T |
convertSendAndReceiveAsType(String exchange,
String routingKey,
Object message,
ParameterizedTypeReference<T> responseType)
Basic RPC pattern with conversion.
|
Message |
receive()
Receive a message if there is one from a default queue.
|
Message |
receive(long timeoutMillis)
Receive a message from a default queue, waiting up to the specified wait time if
necessary for a message to become available.
|
Message |
receive(String queueName)
Receive a message if there is one from a specific queue.
|
Message |
receive(String queueName,
long timeoutMillis)
Receive a message from a specific queue, waiting up to the specified wait time if
necessary for a message to become available.
|
Object |
receiveAndConvert()
Receive a message if there is one from a default queue and convert it to a Java
object.
|
Object |
receiveAndConvert(long timeoutMillis)
Receive a message if there is one from a default queue and convert it to a Java
object.
|
<T> T |
receiveAndConvert(long timeoutMillis,
ParameterizedTypeReference<T> type)
Receive a message if there is one from a default queue and convert it to a Java
object.
|
<T> T |
receiveAndConvert(ParameterizedTypeReference<T> type)
Receive a message if there is one from a default queue and convert it to a Java
object.
|
Object |
receiveAndConvert(String queueName)
Receive a message if there is one from a specific queue and convert it to a Java
object.
|
Object |
receiveAndConvert(String queueName,
long timeoutMillis)
Receive a message if there is one from a specific queue and convert it to a Java
object.
|
<T> T |
receiveAndConvert(String queueName,
long timeoutMillis,
ParameterizedTypeReference<T> type)
Receive a message if there is one from a specific queue and convert it to a Java
object.
|
<T> T |
receiveAndConvert(String queueName,
ParameterizedTypeReference<T> type)
Receive a message if there is one from a specific queue and convert it to a Java
object.
|
<R,S> boolean |
receiveAndReply(ReceiveAndReplyCallback<R,S> callback)
Receive a message if there is one from a default queue, invoke provided
ReceiveAndReplyCallback and send reply message, if the callback
returns one, to the replyTo Address
from MessageProperties or to default exchange
and default routingKey. |
<R,S> boolean |
receiveAndReply(ReceiveAndReplyCallback<R,S> callback,
ReplyToAddressCallback<S> replyToAddressCallback)
Receive a message if there is one from a default queue, invoke provided
ReceiveAndReplyCallback and send reply message, if the callback
returns one, to the replyTo Address
from result of ReplyToAddressCallback . |
<R,S> boolean |
receiveAndReply(ReceiveAndReplyCallback<R,S> callback,
String replyExchange,
String replyRoutingKey)
Receive a message if there is one from default queue, invoke provided
ReceiveAndReplyCallback and send reply message, if the callback
returns one, to the provided exchange and routingKey . |
<R,S> boolean |
receiveAndReply(String queueName,
ReceiveAndReplyCallback<R,S> callback)
Receive a message if there is one from provided queue, invoke provided
ReceiveAndReplyCallback and send reply message, if the callback
returns one, to the replyTo Address
from MessageProperties or to default exchange
and default routingKey. |
<R,S> boolean |
receiveAndReply(String queueName,
ReceiveAndReplyCallback<R,S> callback,
ReplyToAddressCallback<S> replyToAddressCallback)
Receive a message if there is one from provided queue, invoke provided
ReceiveAndReplyCallback and send reply message, if the callback
returns one, to the replyTo Address
from result of ReplyToAddressCallback . |
<R,S> boolean |
receiveAndReply(String queueName,
ReceiveAndReplyCallback<R,S> callback,
String replyExchange,
String replyRoutingKey)
Receive a message if there is one from provided queue, invoke provided
ReceiveAndReplyCallback and send reply message, if the callback
returns one, to the provided exchange and routingKey . |
void |
send(Message message)
Send a message to a default exchange with a default routing key.
|
void |
send(String routingKey,
Message message)
Send a message to a default exchange with a specific routing key.
|
void |
send(String exchange,
String routingKey,
Message message)
Send a message to a specific exchange with a specific routing key.
|
Message |
sendAndReceive(Message message)
Basic RPC pattern.
|
Message |
sendAndReceive(String routingKey,
Message message)
Basic RPC pattern.
|
Message |
sendAndReceive(String exchange,
String routingKey,
Message message)
Basic RPC pattern.
|
void send(Message message) throws AmqpException
message
- a message to sendAmqpException
- if there is a problemvoid send(String routingKey, Message message) throws AmqpException
routingKey
- the routing keymessage
- a message to sendAmqpException
- if there is a problemvoid send(String exchange, String routingKey, Message message) throws AmqpException
exchange
- the name of the exchangeroutingKey
- the routing keymessage
- a message to sendAmqpException
- if there is a problemvoid convertAndSend(Object message) throws AmqpException
Message
and send it to a default exchange
with a default routing key.message
- a message to sendAmqpException
- if there is a problemvoid convertAndSend(String routingKey, Object message) throws AmqpException
Message
and send it to a default exchange
with a specific routing key.routingKey
- the routing keymessage
- a message to sendAmqpException
- if there is a problemvoid convertAndSend(String exchange, String routingKey, Object message) throws AmqpException
Message
and send it to a specific exchange
with a specific routing key.exchange
- the name of the exchangeroutingKey
- the routing keymessage
- a message to sendAmqpException
- if there is a problemvoid convertAndSend(Object message, MessagePostProcessor messagePostProcessor) throws AmqpException
Message
and send it to a default exchange
with a default routing key.message
- a message to sendmessagePostProcessor
- a processor to apply to the message before it is sentAmqpException
- if there is a problemvoid convertAndSend(String routingKey, Object message, MessagePostProcessor messagePostProcessor) throws AmqpException
Message
and send it to a default exchange
with a specific routing key.routingKey
- the routing keymessage
- a message to sendmessagePostProcessor
- a processor to apply to the message before it is sentAmqpException
- if there is a problemvoid convertAndSend(String exchange, String routingKey, Object message, MessagePostProcessor messagePostProcessor) throws AmqpException
Message
and send it to a specific exchange
with a specific routing key.exchange
- the name of the exchangeroutingKey
- the routing keymessage
- a message to sendmessagePostProcessor
- a processor to apply to the message before it is sentAmqpException
- if there is a problem@Nullable Message receive() throws AmqpException
AmqpException
- if there is a problem@Nullable Message receive(String queueName) throws AmqpException
queueName
- the name of the queue to pollAmqpException
- if there is a problem@Nullable Message receive(long timeoutMillis) throws AmqpException
timeoutMillis
- how long to wait before giving up. Zero value means the method
will return null
immediately if there is no message available. Negative
value makes method wait for a message indefinitely.AmqpException
- if there is a problem@Nullable Message receive(String queueName, long timeoutMillis) throws AmqpException
queueName
- the queue to receive fromtimeoutMillis
- how long to wait before giving up. Zero value means the method
will return null
immediately if there is no message available. Negative
value makes method wait for a message indefinitely.AmqpException
- if there is a problem@Nullable Object receiveAndConvert() throws AmqpException
AmqpException
- if there is a problem@Nullable Object receiveAndConvert(String queueName) throws AmqpException
queueName
- the name of the queue to pollAmqpException
- if there is a problem@Nullable Object receiveAndConvert(long timeoutMillis) throws AmqpException
timeoutMillis
- how long to wait before giving up. Zero value means the method
will return null
immediately if there is no message available. Negative
value makes method wait for a message indefinitely.AmqpException
- if there is a problem@Nullable Object receiveAndConvert(String queueName, long timeoutMillis) throws AmqpException
queueName
- the name of the queue to polltimeoutMillis
- how long to wait before giving up. Zero value means the method
will return null
immediately if there is no message available. Negative
value makes method wait for a message indefinitely.AmqpException
- if there is a problem@Nullable <T> T receiveAndConvert(ParameterizedTypeReference<T> type) throws AmqpException
SmartMessageConverter
.T
- the type.type
- the type to convert to.AmqpException
- if there is a problem.@Nullable <T> T receiveAndConvert(String queueName, ParameterizedTypeReference<T> type) throws AmqpException
SmartMessageConverter
.T
- the type.queueName
- the name of the queue to polltype
- the type to convert to.AmqpException
- if there is a problem@Nullable <T> T receiveAndConvert(long timeoutMillis, ParameterizedTypeReference<T> type) throws AmqpException
SmartMessageConverter
.T
- the type.timeoutMillis
- how long to wait before giving up. Zero value means the method
will return null
immediately if there is no message available. Negative
value makes method wait for a message indefinitely.type
- the type to convert to.AmqpException
- if there is a problem@Nullable <T> T receiveAndConvert(String queueName, long timeoutMillis, ParameterizedTypeReference<T> type) throws AmqpException
SmartMessageConverter
.T
- the type.queueName
- the name of the queue to polltimeoutMillis
- how long to wait before giving up. Zero value means the method
will return null
immediately if there is no message available. Negative
value makes method wait for a message indefinitely.type
- the type to convert to.AmqpException
- if there is a problem<R,S> boolean receiveAndReply(ReceiveAndReplyCallback<R,S> callback) throws AmqpException
ReceiveAndReplyCallback
and send reply message, if the callback
returns one, to the replyTo
Address
from MessageProperties
or to default exchange
and default routingKey.R
- The type of the request after conversion from the Message
.S
- The type of the response.callback
- a user-provided ReceiveAndReplyCallback
implementation to
process received message and return a reply message.true
, if message was receivedAmqpException
- if there is a problem<R,S> boolean receiveAndReply(String queueName, ReceiveAndReplyCallback<R,S> callback) throws AmqpException
ReceiveAndReplyCallback
and send reply message, if the callback
returns one, to the replyTo
Address
from MessageProperties
or to default exchange
and default routingKey.R
- The type of the request after conversion from the Message
.S
- The type of the response.queueName
- the queue name to receive a message.callback
- a user-provided ReceiveAndReplyCallback
implementation to
process received message and return a reply message.true
, if message was received.AmqpException
- if there is a problem.<R,S> boolean receiveAndReply(ReceiveAndReplyCallback<R,S> callback, String replyExchange, String replyRoutingKey) throws AmqpException
ReceiveAndReplyCallback
and send reply message, if the callback
returns one, to the provided exchange
and routingKey
.R
- The type of the request after conversion from the Message
.S
- The type of the response.callback
- a user-provided ReceiveAndReplyCallback
implementation to
process received message and return a reply message.replyExchange
- the exchange name to send reply message.replyRoutingKey
- the routing key to send reply message.true
, if message was received.AmqpException
- if there is a problem.<R,S> boolean receiveAndReply(String queueName, ReceiveAndReplyCallback<R,S> callback, String replyExchange, String replyRoutingKey) throws AmqpException
ReceiveAndReplyCallback
and send reply message, if the callback
returns one, to the provided exchange
and routingKey
.R
- The type of the request after conversion from the Message
.S
- The type of the response.queueName
- the queue name to receive a message.callback
- a user-provided ReceiveAndReplyCallback
implementation to
process received message and return a reply message.replyExchange
- the exchange name to send reply message.replyRoutingKey
- the routing key to send reply message.true
, if message was receivedAmqpException
- if there is a problem<R,S> boolean receiveAndReply(ReceiveAndReplyCallback<R,S> callback, ReplyToAddressCallback<S> replyToAddressCallback) throws AmqpException
ReceiveAndReplyCallback
and send reply message, if the callback
returns one, to the replyTo
Address
from result of ReplyToAddressCallback
.R
- The type of the request after conversion from the Message
.S
- The type of the response.callback
- a user-provided ReceiveAndReplyCallback
implementation to
process received message and return a reply message.replyToAddressCallback
- the callback to determine replyTo address at runtime.true
, if message was received.AmqpException
- if there is a problem.<R,S> boolean receiveAndReply(String queueName, ReceiveAndReplyCallback<R,S> callback, ReplyToAddressCallback<S> replyToAddressCallback) throws AmqpException
ReceiveAndReplyCallback
and send reply message, if the callback
returns one, to the replyTo
Address
from result of ReplyToAddressCallback
.R
- The type of the request after conversion from the Message
.S
- The type of the response.queueName
- the queue name to receive a message.callback
- a user-provided ReceiveAndReplyCallback
implementation to
process received message and return a reply message.replyToAddressCallback
- the callback to determine replyTo address at runtime.true
, if message was receivedAmqpException
- if there is a problem@Nullable Message sendAndReceive(Message message) throws AmqpException
message
- a message to sendAmqpException
- if there is a problem@Nullable Message sendAndReceive(String routingKey, Message message) throws AmqpException
routingKey
- the routing keymessage
- a message to sendAmqpException
- if there is a problem@Nullable Message sendAndReceive(String exchange, String routingKey, Message message) throws AmqpException
exchange
- the name of the exchangeroutingKey
- the routing keymessage
- a message to sendAmqpException
- if there is a problem@Nullable Object convertSendAndReceive(Object message) throws AmqpException
message
- a message to sendAmqpException
- if there is a problem@Nullable Object convertSendAndReceive(String routingKey, Object message) throws AmqpException
routingKey
- the routing keymessage
- a message to sendAmqpException
- if there is a problem@Nullable Object convertSendAndReceive(String exchange, String routingKey, Object message) throws AmqpException
exchange
- the name of the exchangeroutingKey
- the routing keymessage
- a message to sendAmqpException
- if there is a problem@Nullable Object convertSendAndReceive(Object message, MessagePostProcessor messagePostProcessor) throws AmqpException
message
- a message to sendmessagePostProcessor
- a processor to apply to the message before it is sentAmqpException
- if there is a problem@Nullable Object convertSendAndReceive(String routingKey, Object message, MessagePostProcessor messagePostProcessor) throws AmqpException
routingKey
- the routing keymessage
- a message to sendmessagePostProcessor
- a processor to apply to the message before it is sentAmqpException
- if there is a problem@Nullable Object convertSendAndReceive(String exchange, String routingKey, Object message, MessagePostProcessor messagePostProcessor) throws AmqpException
exchange
- the name of the exchangeroutingKey
- the routing keymessage
- a message to sendmessagePostProcessor
- a processor to apply to the message before it is sentAmqpException
- if there is a problem@Nullable <T> T convertSendAndReceiveAsType(Object message, ParameterizedTypeReference<T> responseType) throws AmqpException
SmartMessageConverter
.T
- the type.message
- a message to send.responseType
- the type to convert the reply to.AmqpException
- if there is a problem.@Nullable <T> T convertSendAndReceiveAsType(String routingKey, Object message, ParameterizedTypeReference<T> responseType) throws AmqpException
SmartMessageConverter
.T
- the type.routingKey
- the routing keymessage
- a message to sendresponseType
- the type to convert the reply to.AmqpException
- if there is a problem@Nullable <T> T convertSendAndReceiveAsType(String exchange, String routingKey, Object message, ParameterizedTypeReference<T> responseType) throws AmqpException
SmartMessageConverter
.T
- the type.exchange
- the name of the exchangeroutingKey
- the routing keymessage
- a message to sendresponseType
- the type to convert the reply to.AmqpException
- if there is a problem@Nullable <T> T convertSendAndReceiveAsType(Object message, MessagePostProcessor messagePostProcessor, ParameterizedTypeReference<T> responseType) throws AmqpException
SmartMessageConverter
.T
- the type.message
- a message to sendmessagePostProcessor
- a processor to apply to the message before it is sentresponseType
- the type to convert the reply to.AmqpException
- if there is a problem@Nullable <T> T convertSendAndReceiveAsType(String routingKey, Object message, MessagePostProcessor messagePostProcessor, ParameterizedTypeReference<T> responseType) throws AmqpException
SmartMessageConverter
.T
- the type.routingKey
- the routing keymessage
- a message to sendmessagePostProcessor
- a processor to apply to the message before it is sentresponseType
- the type to convert the reply to.AmqpException
- if there is a problem@Nullable <T> T convertSendAndReceiveAsType(String exchange, String routingKey, Object message, MessagePostProcessor messagePostProcessor, ParameterizedTypeReference<T> responseType) throws AmqpException
SmartMessageConverter
.T
- the type.exchange
- the name of the exchangeroutingKey
- the routing keymessage
- a message to sendmessagePostProcessor
- a processor to apply to the message before it is sentresponseType
- the type to convert the reply to.AmqpException
- if there is a problem