8

In my project , I've created a simple pub/sub topic with radisson (https://github.com/redisson/redisson) . Publisher will publish some message and there will be multiple subscribers running on different machines . When I publish , all the subscribers are getting message . But I want anyone of the subscriber to process the message , ie if one process the message , others should simply ignore it . Is it possible with Radisson ?

LISTENER:

RTopic topic = redisson.getTopic("topic2");
topic.addListener(Person.class, new MessageListener<Person>() {
    @Override
    public void onMessage(CharSequence charSequence, Person person) {
        System.out.println("PERSON : "+person.toString());
    }
});

PUBLISHER :

 Person person = new Person("anyName","female");
 RedissonClient redisson = Redisson.create();
 RTopic topic = redisson.getTopic("topic2");
 topic.publish(person);

Is it possible to put lock or something , so that only one subscriber listens it. Will any other tools support this behavior.

EricSchaefer
  • 25,272
  • 21
  • 67
  • 103
shashantrika
  • 1,039
  • 1
  • 9
  • 29
  • Hi @shashantrika did you found a solution? I am facing the same issue – Roie Beck Mar 14 '21 at 10:11
  • 1
    Hi @RoieBeck , nope unfortunately I didn't find any solutions for this , but Im using https://github.com/gresrun/jesque now which seems to fit my solution . – shashantrika Mar 15 '21 at 05:19

1 Answers1

0

Pub-Sub is not designed for this. Read about queues in ActiveMQ/RabbitMQ or SQS, which will fulfil your scenario

Rajeev
  • 183
  • 2
  • 10
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 10 '22 at 07:52