Skip to content

Support competing consumers in Pub/Sub #202

Closed

Description

@jordanliuhao

I have two or more groups of consumer servers subscribed to a channel. When producer server publish a message, I'd like one and only one consumer server in each group get the message.

I need this because the consumer servers are actually load balanced and running different tasks. This feature is important in a scalable network.

I suggest to have a group identity when consumer server subscribe the channel, gid=0 means ungrouped. Then only one server get the notification in one group.

But not necessary to be the best way.

Thanks

Activity

  1. pietern commented on Nov 21, 2011

    @pietern
    Contributor

    You can use a list as message queue instead. Have the publishers push a message to this list, and have clients doing a blocking pop from it. This way, every message will only end up with one client.

  2. antirez commented on Nov 22, 2011

    @antirez
    Contributor

    I suggest what Pieter said. Basically in Redis we have two models for messaging:

    • Pub/Sub that is many-to-may and fire-and-forget (no persistence).
    • Lists: many to N competing listeners, with persistence, optional reliability (BRPOPLPUSH), and so forth.

    We'll try hard to avoid making the semantics more complex trying to create new messaging systems having mixed properties between the former and the latter. When more complex messaging is needed either use a full featured messaging system like RabbitMQ or ask yourself if you can relax the requirements...

    Closing

  3. refaelos commented on Oct 11, 2014

    @refaelos

    @antirez is there a way to do competing listeners on "Keyspace Notifications" ?
    I mean, I need a way for only one of my listeners to be able to handle an EXPIRE notification but as far as I can see there's only the option listen to these notifications using the pub/sub mechanism.

  4. added a commit that references this issue on Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions