Sindhu Raju
Sindhu Raju

Reputation: 311

Redis Pub/Sub persistence

I am working on redis SMQ persistence. My questions here is, While publisher publishing the messages, consumer has stopped suddenly. When consumer connects again, is it possible to subscribe messages from where it has stopped?

Upvotes: 12

Views: 10024

Answers (3)

Sergey Shuchkin
Sergey Shuchkin

Reputation: 2197

Plz use 2 redis connections: 1 pubsub, second - LPOP/RPOP

Upvotes: 0

Ismayil Niftaliyev
Ismayil Niftaliyev

Reputation: 396

With standard Pub/Sub you can use Lua scripts to persist your message. You need to check whether you have a listener on channel or not. If not then storing your message with channel key on redis . When the subscriber cames back it checks if there is anything for him based on channel key. Second option is to use Redis Stream. Check this gist.

Upvotes: 4

Itamar Haber
Itamar Haber

Reputation: 49932

No - Redis' Pub/Sub has no persistence, and once a message has been published, it is sent only to the connected subscribed clients. Afterwards, the message is gone forever.

Upvotes: 17

Related Questions