Search code examples
javaspringrabbitmqspring-cloud

Spring cloud stream RabbitMq - Set properties from source code


I am using Spring cloud stream with RabbitMQ.

I want to be able to configure message and query properties from source code and not from a property file (as they mention in their docs).

For example with the classic Java Client for RabbitMq i can do something like that to create a queue with the properties i want:

                    //qName,    passive, durable, exclusive  auto-delete
channel.queueDeclare("myQueue", true,    false,   false,   , false       , null);

Any ideas on how can i achieve the same thing using Spring cloud stream?


Solution

  • After digging in their documentation and with the help of @vaquar khan I found out that the only way to do it is from your property file.

    application.yml

    spring:
      cloud:
        stream:
          bindings:
            queue_name :
              destination: queue_name
              group: your_group_name 
              durable-subscription : true
    

    This will declare a durable, non-deleting and non-exclusive queue.