Two or more consumers for different queues

Options
murillocg
murillocg Member Posts: 11
edited October 2022 in PubSub+ Event Broker #1

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.

Tagged:

Best Answer

  • Aaron
    Aaron Member, Administrator, Moderator, Employee Posts: 531 admin
    #2 Answer ✓
    Options

    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.java

Answers

  • Aaron
    Aaron Member, Administrator, Moderator, Employee Posts: 531 admin
    #3 Answer ✓
    Options

    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.java

  • murillocg
    murillocg Member Posts: 11
    Options

    Hi @Aaron

    That's exactly what I need, Guaranteed messages! So I have to create FlowReceivers!

    Thanks a lot!