Spring AMQP

org.springframework.amqp.core
Interface AmqpTemplate

All Known Subinterfaces:
RabbitOperations
All Known Implementing Classes:
RabbitTemplate

public interface AmqpTemplate

Specifies a basic set of AMQP operations. Provides synchronous send and receive methods. The 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.

Author:
Mark Pollack, Mark Fisher

Method Summary
 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.
 Message receive()
          Receive a message if there is one from a default queue.
 Message receive(String queueName)
          Receive a message if there is one from a specific queue.
 Object receiveAndConvert()
          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.
 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.
 

Method Detail

send

void send(Message message)
          throws AmqpException
Send a message to a default exchange with a default routing key.

Parameters:
message - a message to send
Throws:
AmqpException - if there is a problem

send

void send(String routingKey,
          Message message)
          throws AmqpException
Send a message to a default exchange with a specific routing key.

Parameters:
routingKey - the routing key
message - a message to send
Throws:
AmqpException - if there is a problem

send

void send(String exchange,
          String routingKey,
          Message message)
          throws AmqpException
Send a message to a specific exchange with a specific routing key.

Parameters:
exchange - the name of the exchange
routingKey - the routing key
message - a message to send
Throws:
AmqpException - if there is a problem

convertAndSend

void convertAndSend(Object message)
                    throws AmqpException
Convert a Java object to an Amqp Message and send it to a default exchange with a default routing key.

Parameters:
message - a message to send
Throws:
AmqpException - if there is a problem

convertAndSend

void convertAndSend(String routingKey,
                    Object message)
                    throws AmqpException
Convert a Java object to an Amqp Message and send it to a default exchange with a specific routing key.

Parameters:
routingKey - the routing key
message - a message to send
Throws:
AmqpException - if there is a problem

convertAndSend

void convertAndSend(String exchange,
                    String routingKey,
                    Object message)
                    throws AmqpException
Convert a Java object to an Amqp Message and send it to a specific exchange with a specific routing key.

Parameters:
exchange - the name of the exchange
routingKey - the routing key
message - a message to send
Throws:
AmqpException - if there is a problem

convertAndSend

void convertAndSend(Object message,
                    MessagePostProcessor messagePostProcessor)
                    throws AmqpException
Convert a Java object to an Amqp Message and send it to a default exchange with a default routing key.

Parameters:
message - a message to send
messagePostProcessor - a processor to apply to the message before it is sent
Throws:
AmqpException - if there is a problem

convertAndSend

void convertAndSend(String routingKey,
                    Object message,
                    MessagePostProcessor messagePostProcessor)
                    throws AmqpException
Convert a Java object to an Amqp Message and send it to a default exchange with a specific routing key.

Parameters:
routingKey - the routing key
message - a message to send
messagePostProcessor - a processor to apply to the message before it is sent
Throws:
AmqpException - if there is a problem

convertAndSend

void convertAndSend(String exchange,
                    String routingKey,
                    Object message,
                    MessagePostProcessor messagePostProcessor)
                    throws AmqpException
Convert a Java object to an Amqp Message and send it to a specific exchange with a specific routing key.

Parameters:
exchange - the name of the exchange
routingKey - the routing key
message - a message to send
messagePostProcessor - a processor to apply to the message before it is sent
Throws:
AmqpException - if there is a problem

receive

Message receive()
                throws AmqpException
Receive a message if there is one from a default queue. Returns immediately, possibly with a null value.

Returns:
a message or null if there is none waiting
Throws:
AmqpException - if there is a problem

receive

Message receive(String queueName)
                throws AmqpException
Receive a message if there is one from a specific queue. Returns immediately, possibly with a null value.

Parameters:
queueName - the name of the queue to poll
Returns:
a message or null if there is none waiting
Throws:
AmqpException - if there is a problem

receiveAndConvert

Object receiveAndConvert()
                         throws AmqpException
Receive a message if there is one from a default queue and convert it to a Java object. Returns immediately, possibly with a null value.

Returns:
a message or null if there is none waiting
Throws:
AmqpException - if there is a problem

receiveAndConvert

Object receiveAndConvert(String queueName)
                         throws AmqpException
Receive a message if there is one from a specific queue and convert it to a Java object. Returns immediately, possibly with a null value.

Parameters:
queueName - the name of the queue to poll
Returns:
a message or null if there is none waiting
Throws:
AmqpException - if there is a problem

sendAndReceive

Message sendAndReceive(Message message)
                       throws AmqpException
Basic RPC pattern. Send a message to a default exchange with a default routing key and attempt to receive a response. 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
Returns:
the response if there is one
Throws:
AmqpException - if there is a problem

sendAndReceive

Message sendAndReceive(String routingKey,
                       Message message)
                       throws AmqpException
Basic RPC pattern. Send a message to a default exchange with a specific routing key and attempt to receive a response. 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 key
message - a message to send
Returns:
the response if there is one
Throws:
AmqpException - if there is a problem

sendAndReceive

Message sendAndReceive(String exchange,
                       String routingKey,
                       Message message)
                       throws AmqpException
Basic RPC pattern. Send a message to a specific exchange with a specific routing key and attempt to receive a response. 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 exchange
routingKey - the routing key
message - a message to send
Returns:
the response if there is one
Throws:
AmqpException - if there is a problem

convertSendAndReceive

Object convertSendAndReceive(Object message)
                             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
Returns:
the response if there is one
Throws:
AmqpException - if there is a problem

convertSendAndReceive

Object convertSendAndReceive(String routingKey,
                             Object message)
                             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 key
message - a message to send
Returns:
the response if there is one
Throws:
AmqpException - if there is a problem

convertSendAndReceive

Object convertSendAndReceive(String exchange,
                             String routingKey,
                             Object message)
                             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 exchange
routingKey - the routing key
message - a message to send
Returns:
the response if there is one
Throws:
AmqpException - if there is a problem

convertSendAndReceive

Object convertSendAndReceive(Object message,
                             MessagePostProcessor messagePostProcessor)
                             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
messagePostProcessor - a processor to apply to the message before it is sent
Returns:
the response if there is one
Throws:
AmqpException - if there is a problem

convertSendAndReceive

Object convertSendAndReceive(String routingKey,
                             Object message,
                             MessagePostProcessor messagePostProcessor)
                             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 key
message - a message to send
messagePostProcessor - a processor to apply to the message before it is sent
Returns:
the response if there is one
Throws:
AmqpException - if there is a problem

convertSendAndReceive

Object convertSendAndReceive(String exchange,
                             String routingKey,
                             Object message,
                             MessagePostProcessor messagePostProcessor)
                             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 exchange
routingKey - the routing key
message - a message to send
messagePostProcessor - a processor to apply to the message before it is sent
Returns:
the response if there is one
Throws:
AmqpException - if there is a problem

Spring AMQP