🎄 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.
Two or more consumers for different queues
In this example, I see only one consumer, in one subscription like here: https://github.com/SolaceSamples/solace-samples-java-jcsmp/blob/master/src/main/java/com/solace/samples/jcsmp/HelloWorld.java
How should I create one consumer/listener for different queues? For instance, one consumer for certificateUpdate and another for saveFile, with different types of messages, and separate classes to consume.
Best Answer
-
Hi @murillocg . The HelloWorld samples use Direct messaging. If you're talking about queues, then I'd infer that you want to use Guaranteed messaging. Do you know which you need?
First off, for different types of messages, then I hope you're publishing these on different topics.
If using Direct messages, you could have one subscriber with multiple subscriptions... just add more subscriptions, to the same consumer.
For Guaranteed messages, you'd still publish on topics, make sure the Delivery Mode is set to
PERSISTENT
, and then you could have one queue with multiple subscriptions, or two queues each subscribed to your specific topics. If two queues, but being processed by the same app, then you'd have to create two FlowReceivers. See here for a related sample: https://github.com/SolaceSamples/solace-samples-java-jcsmp/blob/master/src/main/java/com/solace/samples/jcsmp/patterns/GuaranteedSubscriber.java2
Answers
-
Hi @murillocg . The HelloWorld samples use Direct messaging. If you're talking about queues, then I'd infer that you want to use Guaranteed messaging. Do you know which you need?
First off, for different types of messages, then I hope you're publishing these on different topics.
If using Direct messages, you could have one subscriber with multiple subscriptions... just add more subscriptions, to the same consumer.
For Guaranteed messages, you'd still publish on topics, make sure the Delivery Mode is set to
PERSISTENT
, and then you could have one queue with multiple subscriptions, or two queues each subscribed to your specific topics. If two queues, but being processed by the same app, then you'd have to create two FlowReceivers. See here for a related sample: https://github.com/SolaceSamples/solace-samples-java-jcsmp/blob/master/src/main/java/com/solace/samples/jcsmp/patterns/GuaranteedSubscriber.java2