0

I am using spring-boot integrated with rabbitMQ. I mean construction as in this tutorial:
https://spring.io/guides/gs/messaging-rabbitmq/

I would like to do following thing:
Use application.properties to define host, port, username, password to rabbitmq server.
Now in some class:

class SomeClass {
   @Autowired
   private SomeConnectionToRabbit conn;

   void x(String queueName) {
      use conn to get messages from some queue queueName
      don't close connection, it will be needed in future.
   }

}

To sum up, I am searching for solution to following problem: autowire instance of one connection to rabbitmq, use and reuse this connection to get messages from different queues (get messages means that I get all messages and I don't need to handle newly pushed messages).

Any ideas ?

  • Everything what we have there is described in the Reference Manual: http://docs.spring.io/spring-amqp/reference/html/_reference.html#connections – Artem Bilan Mar 21 '17 at 19:10
  • @ArtemBilan I read it in a moment. Tell me only if it is possbile to do it ? –  Mar 21 '17 at 19:12
  • There is something like this in test code: https://github.com/spring-projects/spring-amqp/blob/master/spring-rabbit/src/test/java/org/springframework/amqp/rabbit/connection/SingleConnectionFactory.java. But we don't encourage to use such a solution in production, because of leak of management. That's why existing (default) `CachingConnectionFactory` is much better. – Artem Bilan Mar 21 '17 at 19:12
  • @ArtemBilan you now my context now. Could you help here http://stackoverflow.com/questions/42935642/dynamic-binding-multi-queue-to-one-handler ? –  Mar 21 '17 at 19:17

0 Answers0