|
Spring AMQP | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.amqp.rabbit.support.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.support.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)
|
|
protected void |
doSend(com.rabbitmq.client.Channel channel,
String exchange,
String routingKey,
MessageCreator messageCreator)
Send the given message to the specified exchange. |
|
|
execute(ChannelCallback<T> action)
|
|
protected com.rabbitmq.client.Channel |
getChannel(RabbitResourceHolder holder)
Fetch an appropriate Channel from the given RabbitResourceHolder. |
|
protected com.rabbitmq.client.Connection |
getConnection(RabbitResourceHolder holder)
Fetch an appropriate Connection from the given RabbitResourceHolder. |
|
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(MessageCreator messageCreator)
|
|
void |
send(String routingKey,
MessageCreator messageCreator)
|
|
void |
send(String exchange,
String routingKey,
MessageCreator messageCreator)
|
|
void |
setExchange(String exchange)
|
|
void |
setImmediatePublish(boolean immediatePublish)
|
|
void |
setMandatoryPublish(boolean mandatoryPublish)
|
|
void |
setMessageConverter(MessageConverter messageConverter)
Set the message converter for this template. |
|
void |
setQueue(String queue)
|
|
void |
setRequireAck(boolean requireAck)
|
|
void |
setRoutingKey(String routingKey)
|
|
| Methods inherited from class org.springframework.amqp.rabbit.support.RabbitAccessor |
|---|
afterPropertiesSet, convertRabbitAccessException, createChannel, createConnection, getConnectionFactory, 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 setMandatoryPublish(boolean mandatoryPublish)
public void setImmediatePublish(boolean immediatePublish)
public void setRequireAck(boolean requireAck)
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(),
org.springframework.amqp.support.converter.rabbit.support.converter.SimpleMessageConverterpublic MessageConverter getMessageConverter()
protected com.rabbitmq.client.Connection getConnection(RabbitResourceHolder holder)
holder - the RabbitResourceHolder
null if none foundprotected com.rabbitmq.client.Channel getChannel(RabbitResourceHolder holder)
holder - the RabbitResourceHolder
null if none found
public void send(MessageCreator messageCreator)
throws AmqpException
send in interface AmqpTemplateAmqpException
public void send(String routingKey,
MessageCreator messageCreator)
throws AmqpException
send in interface AmqpTemplateAmqpException
public void send(String exchange,
String routingKey,
MessageCreator messageCreator)
throws AmqpException
send in interface AmqpTemplateAmqpException
public void convertAndSend(Object object)
throws AmqpException
convertAndSend in interface AmqpTemplateAmqpException
public void convertAndSend(String routingKey,
Object object)
throws AmqpException
convertAndSend in interface AmqpTemplateAmqpException
public void convertAndSend(String exchange,
String routingKey,
Object object)
throws AmqpException
convertAndSend in interface AmqpTemplateAmqpException
public void convertAndSend(Object message,
MessagePostProcessor messagePostProcessor)
throws AmqpException
convertAndSend in interface AmqpTemplateAmqpException
public void convertAndSend(String routingKey,
Object message,
MessagePostProcessor messagePostProcessor)
throws AmqpException
convertAndSend in interface AmqpTemplateAmqpException
public void convertAndSend(String exchange,
String routingKey,
Object message,
MessagePostProcessor messagePostProcessor)
throws AmqpException
convertAndSend in interface AmqpTemplateAmqpException
public Message receive()
throws AmqpException
receive in interface AmqpTemplateAmqpExceptionpublic Message receive(String queueName)
receive in interface AmqpTemplate
public Object receiveAndConvert()
throws AmqpException
receiveAndConvert in interface AmqpTemplateAmqpException
public Object receiveAndConvert(String queueName)
throws AmqpException
receiveAndConvert in interface AmqpTemplateAmqpExceptionpublic <T> T execute(ChannelCallback<T> action)
execute in interface RabbitOperations
protected void doSend(com.rabbitmq.client.Channel channel,
String exchange,
String routingKey,
MessageCreator messageCreator)
throws Exception
channel - the RabbitMQ Channel to operate withinexchange - the name of the RabbitMQ exchange to send toroutingKey - the routing key tomessageCreator - callback to create a Message
IOException - if thrown by RabbitMQ API methods
Exceptionprotected 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 | |||||||||