Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As i know RabbitMQ <em>does not</em> support XA style transactions.</p> <p>And yes you can do it in Java:</p> <p><strong>TestConfiguration.java</strong></p> <pre><code>import org.springframework.amqp.core.Queue; import org.springframework.amqp.rabbit.config.AbstractRabbitConfiguration; import org.springframework.amqp.rabbit.connection.ConnectionFactory; import org.springframework.amqp.rabbit.connection.SingleConnectionFactory; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class TestConfiguration extends AbstractRabbitConfiguration { private String routingKey = "test.queue"; private String testQueueName = "test.queue"; public ConnectionFactory getConnectionFactory() { SingleConnectionFactory connectionFactory = new SingleConnectionFactory("localhost"); connectionFactory.setUsername("guest"); connectionFactory.setPassword("guest"); return connectionFactory; } @Override public RabbitTemplate rabbitTemplate() { RabbitTemplate rabbitTemplate = new RabbitTemplate(getConnectionFactory()); rabbitTemplate.setRoutingKey(routingKey); rabbitTemplate.setQueue(testQueueName); return rabbitTemplate; </code></pre> <p><strong>Simple example of send:</strong></p> <pre><code>import org.springframework.amqp.core.AmqpTemplate; import org.springframework.beans.factory.annotation.Autowired; public class MessageSender { @Autowired private AmqpTemplate template; public void send(String text) { template.convertAndSend(text); } } </code></pre> <p><strong>..and receive:</strong></p> <pre><code>import org.springframework.amqp.core.Message; import org.springframework.amqp.core.MessageListener; public class MessageHandler implements MessageListener { @Override public void onMessage(Message message) { System.out.println("Received message: " + message); } } </code></pre> <ul> <li>Here are some references <ul> <li><a href="http://static.springsource.org/spring-amqp/docs/1.0.x/reference/html/#d0e692" rel="nofollow">Spring AMQP - Reference Documentation</a></li> <li><a href="http://www.digitalsanctum.com/2010/08/31/using-rabbitmq,-spring-amqp-and-spring-integration/" rel="nofollow">Using RabbitMQ, Spring AMQP and Spring Integration</a></li> <li><a href="http://static.springsource.org/spring-amqp/docs/1.0.x/apidocs/org/springframework/amqp/rabbit/connection/ConnectionFactoryUtils.ResourceFactory.html" rel="nofollow">Spring Framework AMQP RabbitMQ Connection</a></li> <li><a href="http://krams915.blogspot.com.es/search/label/RabbitMQ" rel="nofollow">Blog</a> (detailed descriptions about all process that need to be configured in Java in the case of one application event management )</li> </ul></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload