|
Spring AMQP | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.amqp.rabbit.connection.RabbitAccessor
org.springframework.amqp.rabbit.core.RabbitTemplate
public class RabbitTemplate
Helper class that simplifies synchronous RabbitMQ access code.
Field Summary |
---|
Fields inherited from class org.springframework.amqp.rabbit.connection.RabbitAccessor |
---|
logger |
Constructor Summary | |
---|---|
RabbitTemplate()
|
|
RabbitTemplate(ConnectionFactory connectionFactory)
|
Method Summary | ||
---|---|---|
void |
convertAndSend(Object object)
|
|
void |
convertAndSend(Object message,
MessagePostProcessor messagePostProcessor)
|
|
void |
convertAndSend(String routingKey,
Object object)
|
|
void |
convertAndSend(String routingKey,
Object message,
MessagePostProcessor messagePostProcessor)
|
|
void |
convertAndSend(String exchange,
String routingKey,
Object object)
|
|
void |
convertAndSend(String exchange,
String routingKey,
Object message,
MessagePostProcessor messagePostProcessor)
|
|
Object |
convertSendAndReceive(Object message)
|
|
Object |
convertSendAndReceive(Object message,
MessagePostProcessor messagePostProcessor)
|
|
Object |
convertSendAndReceive(String routingKey,
Object message)
|
|
Object |
convertSendAndReceive(String routingKey,
Object message,
MessagePostProcessor messagePostProcessor)
|
|
Object |
convertSendAndReceive(String exchange,
String routingKey,
Object message)
|
|
Object |
convertSendAndReceive(String exchange,
String routingKey,
Object message,
MessagePostProcessor messagePostProcessor)
|
|
protected void |
doSend(com.rabbitmq.client.Channel channel,
String exchange,
String routingKey,
Message message)
Send the given message to the specified exchange. |
|
protected Message |
doSendAndReceive(String exchange,
String routingKey,
Message message)
Send a message and wait for a reply. |
|
|
execute(ChannelCallback<T> action)
|
|
MessageConverter |
getMessageConverter()
Return the message converter for this template. |
|
protected void |
initDefaultStrategies()
|
|
protected boolean |
isChannelLocallyTransacted(com.rabbitmq.client.Channel channel)
Check whether the given Channel is locally transacted, that is, whether its transaction is managed by this template's Channel handling and not by an external transaction coordinator. |
|
Message |
receive()
|
|
Message |
receive(String queueName)
|
|
Object |
receiveAndConvert()
|
|
Object |
receiveAndConvert(String queueName)
|
|
void |
send(Message message)
|
|
void |
send(String routingKey,
Message message)
|
|
void |
send(String exchange,
String routingKey,
Message message)
|
|
Message |
sendAndReceive(Message message)
|
|
Message |
sendAndReceive(String routingKey,
Message message)
|
|
Message |
sendAndReceive(String exchange,
String routingKey,
Message message)
|
|
void |
setEncoding(String encoding)
The encoding to use when inter-converting between byte arrays and Strings in message properties. |
|
void |
setExchange(String exchange)
|
|
void |
setMessageConverter(MessageConverter messageConverter)
Set the message converter for this template. |
|
void |
setMessagePropertiesConverter(MessagePropertiesConverter messagePropertiesConverter)
Set the MessagePropertiesConverter for this template. |
|
void |
setQueue(String queue)
|
|
void |
setReplyTimeout(long replyTimeout)
Specify the timeout in milliseconds to be used when waiting for a reply Message when using one of the sendAndReceive methods. |
|
void |
setRoutingKey(String routingKey)
|
Methods inherited from class org.springframework.amqp.rabbit.connection.RabbitAccessor |
---|
afterPropertiesSet, convertRabbitAccessException, createConnection, getChannel, getConnection, getConnectionFactory, getTransactionalResourceHolder, isChannelTransacted, setChannelTransacted, setConnectionFactory |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RabbitTemplate()
public RabbitTemplate(ConnectionFactory connectionFactory)
Method Detail |
---|
protected void initDefaultStrategies()
public void setExchange(String exchange)
public void setRoutingKey(String routingKey)
public void setQueue(String queue)
public void setEncoding(String encoding)
encoding
- the encoding to setpublic void setReplyTimeout(long replyTimeout)
DEFAULT_REPLY_TIMEOUT
. A negative value
indicates an indefinite timeout.
public void setMessageConverter(MessageConverter messageConverter)
The default converter is a SimpleMessageConverter, which is able to handle byte arrays, Strings, and Serializable Objects.
convertAndSend(java.lang.Object)
,
receiveAndConvert()
,
SimpleMessageConverter
public void setMessagePropertiesConverter(MessagePropertiesConverter messagePropertiesConverter)
MessagePropertiesConverter
for this template.
public MessageConverter getMessageConverter()
public void send(Message message) throws AmqpException
send
in interface AmqpTemplate
AmqpException
public void send(String routingKey, Message message) throws AmqpException
send
in interface AmqpTemplate
AmqpException
public void send(String exchange, String routingKey, Message message) throws AmqpException
send
in interface AmqpTemplate
AmqpException
public void convertAndSend(Object object) throws AmqpException
convertAndSend
in interface AmqpTemplate
AmqpException
public void convertAndSend(String routingKey, Object object) throws AmqpException
convertAndSend
in interface AmqpTemplate
AmqpException
public void convertAndSend(String exchange, String routingKey, Object object) throws AmqpException
convertAndSend
in interface AmqpTemplate
AmqpException
public void convertAndSend(Object message, MessagePostProcessor messagePostProcessor) throws AmqpException
convertAndSend
in interface AmqpTemplate
AmqpException
public void convertAndSend(String routingKey, Object message, MessagePostProcessor messagePostProcessor) throws AmqpException
convertAndSend
in interface AmqpTemplate
AmqpException
public void convertAndSend(String exchange, String routingKey, Object message, MessagePostProcessor messagePostProcessor) throws AmqpException
convertAndSend
in interface AmqpTemplate
AmqpException
public Message receive() throws AmqpException
receive
in interface AmqpTemplate
AmqpException
public Message receive(String queueName)
receive
in interface AmqpTemplate
public Object receiveAndConvert() throws AmqpException
receiveAndConvert
in interface AmqpTemplate
AmqpException
public Object receiveAndConvert(String queueName) throws AmqpException
receiveAndConvert
in interface AmqpTemplate
AmqpException
public Message sendAndReceive(Message message) throws AmqpException
sendAndReceive
in interface AmqpTemplate
AmqpException
public Message sendAndReceive(String routingKey, Message message) throws AmqpException
sendAndReceive
in interface AmqpTemplate
AmqpException
public Message sendAndReceive(String exchange, String routingKey, Message message) throws AmqpException
sendAndReceive
in interface AmqpTemplate
AmqpException
public Object convertSendAndReceive(Object message) throws AmqpException
convertSendAndReceive
in interface AmqpTemplate
AmqpException
public Object convertSendAndReceive(String routingKey, Object message) throws AmqpException
convertSendAndReceive
in interface AmqpTemplate
AmqpException
public Object convertSendAndReceive(String exchange, String routingKey, Object message) throws AmqpException
convertSendAndReceive
in interface AmqpTemplate
AmqpException
public Object convertSendAndReceive(Object message, MessagePostProcessor messagePostProcessor) throws AmqpException
convertSendAndReceive
in interface AmqpTemplate
AmqpException
public Object convertSendAndReceive(String routingKey, Object message, MessagePostProcessor messagePostProcessor) throws AmqpException
convertSendAndReceive
in interface AmqpTemplate
AmqpException
public Object convertSendAndReceive(String exchange, String routingKey, Object message, MessagePostProcessor messagePostProcessor) throws AmqpException
convertSendAndReceive
in interface AmqpTemplate
AmqpException
protected Message doSendAndReceive(String exchange, String routingKey, Message message)
exchange
- the exchange nameroutingKey
- the routing keymessage
- the message to send
public <T> T execute(ChannelCallback<T> action)
execute
in interface RabbitOperations
protected void doSend(com.rabbitmq.client.Channel channel, String exchange, String routingKey, Message message) throws Exception
channel
- the RabbitMQ Channel to operate withinexchange
- the name of the RabbitMQ exchange to send toroutingKey
- the routing keymessage
- the Message to send
IOException
- if thrown by RabbitMQ API methods
Exception
protected boolean isChannelLocallyTransacted(com.rabbitmq.client.Channel channel)
channel
- the Channel to check
ConnectionFactoryUtils.isChannelTransactional(com.rabbitmq.client.Channel, org.springframework.amqp.rabbit.connection.ConnectionFactory)
,
RabbitAccessor.isChannelTransacted()
|
Spring AMQP | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |