Try PubSub+

In Spring cloud , i would like to read data from pre-define queue.

manzarulmanzarul Member Posts: 16

Currently spring cloud app will create the queue "scst/an/some randome-id/plain/myConsumer-in-0" at server startup (some thing similar), Since i already have a queue and queue has some persistence message so how to command spring cloud to use existing queue for subscriptions.

Best Answer

  • marcmarc Member, Administrator, Moderator, Employee Posts: 568 admin
    #2 Accepted Answer

    Hi @manzarul,

    If I understand you right, you're wanting to have your Spring Cloud Stream app consume from a pre-provisioned queue that already has the proper topic subscriptions on it. AND that pre-provisioned queue does not follow the naming convention that the Cloud Stream binder expects. Correct?

    By default the Solace binder uses this generated Queue Name Syntax. You can adjust each part of that syntax using the available Solace binder consumer properties. To do what you want your config would look something like below. With that config your app would listen on the myQueue queue. It will also not try to provision the queue or topic subscriptions on the queue. Note we plan on making it easier to use custom queue names easier in a future release :)

    spring:
      cloud:
        function:
          definition: myConsumer
        stream:
          bindings:
            myConsumer-in-0:
              destination: myQueue
              group: nonexclusive
          solace:
            bindings:
              myConsumer-in-0:
                consumer:
                  provisionSubscriptionsToDurableQueue: false
                  provisionDurableQueue: false
                  queueNamePrefix: ""
                  useFamiliarityInQueueName: false
                  useDestinationEncodingInQueueName: false
                  useGroupNameInQueueName: false
    

Answers

  • marcmarc Member, Administrator, Moderator, Employee Posts: 568 admin
    #3 Accepted Answer

    Hi @manzarul,

    If I understand you right, you're wanting to have your Spring Cloud Stream app consume from a pre-provisioned queue that already has the proper topic subscriptions on it. AND that pre-provisioned queue does not follow the naming convention that the Cloud Stream binder expects. Correct?

    By default the Solace binder uses this generated Queue Name Syntax. You can adjust each part of that syntax using the available Solace binder consumer properties. To do what you want your config would look something like below. With that config your app would listen on the myQueue queue. It will also not try to provision the queue or topic subscriptions on the queue. Note we plan on making it easier to use custom queue names easier in a future release :)

    spring:
      cloud:
        function:
          definition: myConsumer
        stream:
          bindings:
            myConsumer-in-0:
              destination: myQueue
              group: nonexclusive
          solace:
            bindings:
              myConsumer-in-0:
                consumer:
                  provisionSubscriptionsToDurableQueue: false
                  provisionDurableQueue: false
                  queueNamePrefix: ""
                  useFamiliarityInQueueName: false
                  useDestinationEncodingInQueueName: false
                  useGroupNameInQueueName: false
    
  • manzarulmanzarul Member Posts: 16

    Thanks your suggestion is working.

  • marcmarc Member, Administrator, Moderator, Employee Posts: 568 admin

    Excellent, glad I could help!

  • manzarulmanzarul Member Posts: 16

    This can be closed now.

  • Monica GavaliMonica Gavali Member Posts: 17
    edited October 1 #7

    Hi Mark ,

    I am trying to connect to predefined company provided queue(BRV_INTRADAY_TEST). Did same changes like above but still consumer is not able to pull messages from queue. there is no group for BRV_INTRADAY_TEST.

    Sharing yaml file below:

    spring:
      cloud:
        function:
          definition: receiveAll
        stream:
          bindings:
            receiveAll-in-0:
              destination: BRV_INTRADAY_TEST
          solace:
            bindings:
              receiveAll-in-0:
                consumer:
                  provisionSubscriptionsToDurableQueue: false
                  provisionDurableQueue: false
                  queueNamePrefix: ""
                  useFamiliarityInQueueName: false
                  useDestinationEncodingInQueueName: false
                  useGroupNameInQueueName: false
          binders:
            local-solace:
              type: solace
              environment:
                solace:
                  java:
                    host: host01
                    msgVpn: msgVpn01
                    clientUsername: clientUsername01
                    clientPassword: clientPassword01
    
  • marcmarc Member, Administrator, Moderator, Employee Posts: 568 admin

    Hi @Monica Gavali,

    Did you get an error? or you're just not seeing it bind to the expect queue name? I think the potential point of confusion here is that the solace binder uses durable queues to implement the consumer group pattern and temporary queues to implement the publish-subscribe pattern as defined by Spring Cloud Stream. So if you're not using a group it will not be trying to bind to a existing durable queue because it instead if creating a unique temporary queue for this application. I think it would be worth taking a look at the Communication Models and How to Choose section of the Spring Cloud Stream - Beyond the Basics codelab that I think can help clarify this.

    Hope that helps!

  • Monica GavaliMonica Gavali Member Posts: 17

    ok.. Thanks !!! :)

Sign In or Register to comment.