Solace Community is getting a facelift!

On March 3rd we will be starting the process of migrating Solace Community to a new platform. As a result, Solace Community will go in to a temporary read-only state. You will still be able to come onto Solace Community and search through posts to find answers, but you won't be able to ask questions, post comments, or react in any way.

We hope to have the migration complete by Wednesday March 5th (or sooner), so please keep an eye out!

Two or more consumers for different queues

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: 668 admin
    #2 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.java

Answers

  • Aaron
    Aaron Member, Administrator, Moderator, Employee Posts: 668 admin
    #3 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.java

  • murillocg
    murillocg Member Posts: 11

    Hi @Aaron

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

    Thanks a lot!

This Month's Leaders

This Week's Leaders