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