In Spring cloud , i would like to read data from pre-define queue.
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
-
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 releasespring: 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
1
Answers
-
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 releasespring: 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
1 -
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
0 -
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!
0 -
ok.. Thanks !!!
0 -
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())' .
0