🎄 Happy Holidays! 🥳

Most of Solace is closed December 24–January 1 so our employees can spend time with their families. We will re-open Thursday, January 2, 2024. Please expect slower response times during this period and open a support ticket for anything needing immediate assistance.

Happy Holidays!

Please note: most of Solace is closed December 25–January 2, and will re-open Tuesday, January 3, 2023.

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

manzarul
manzarul Member Posts: 20 ✭✭✭

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

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 963 admin
    #2 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

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 963 admin
    #3 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
    
  • manzarul
    manzarul Member Posts: 20 ✭✭✭

    Thanks your suggestion is working.

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 963 admin

    Excellent, glad I could help!

  • manzarul
    manzarul Member Posts: 20 ✭✭✭

    This can be closed now.

  • Monica Gavali
    Monica Gavali Member Posts: 15
    edited October 2021 #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
    
  • marc
    marc Member, Administrator, Moderator, Employee Posts: 963 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 Gavali
    Monica Gavali Member Posts: 15

    ok.. Thanks !!! :)

  • chatumoh
    chatumoh Member Posts: 7

    I am using @StreamListner, created  input binding of type SubscribableChannel & trying to connect to a pre-provisioned queue and used similar configurations as suggested in previous comment but i am not able to bind consumer with queue .

    Getting error - "EL1008E: Property or field 'isAnonymous' cannot be found on object of type 'com.solace.spring.cloud.stream.binder.provisioning.ExpressionContextRoot' - maybe not public or not valid?" .

    Did try providing queue-name-expression as well as string literal as suggested in blog post https://solace.com/blog/custom-name-for-queues-spring-cloud-stream-binder/ nothing seems to work i keep in getting above error or SpelExpression error i.e. Caused by: org.springframework.expression.spel.SpelParseException: EL1041E: After parsing a valid expression, there is still more data in the expression: 'rparen())' .

  • Aaron
    Aaron Member, Administrator, Moderator, Employee Posts: 644 admin
    edited April 2023 #11

    @chatumoh can you start a new discussion please?

    EDIT: nevermind, I saw that you did.