1
votes

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?

2

2 Answers

1
votes

Inside of "application.yml" you can add all this values , following is example

spring:
  cloud:
    stream:
      instance-count: 1
      bindings:
        input:
          consumer:
            concurrency: 2
            maxAttempts: 1
          group: geode-sink
          destination: jdbc-event-result
          binder: rabbit
      rabbit:
        bindings:
          input:
            consumer:
              autoBindDlq: true
              republishToDlq: true
              requeueRejected: false

rabbitmq:
    username: ur-user-name
    password: ur-password
    host: rabbitmq-url-replace-here
    port: 5672
datasource:
  platform: mysql
  url: jdbc:mysql-url-replace-here
  username: ur-user-name
  password: ur-password
  driverClassName: com.mysql.jdbc.Driver

  datasource:
    tomcat:
      max-wait:  300
      min-idle: 10
      max-idle: 100

aggregator:
  groupCount: 2
  batchSize: 1000
  batchTimeout: 1000

Updated :

1
votes

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.