Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 468
Sindhu Raju Avatar asked May 09 '18 06:05

Sindhu Raju


Video Answer


2 Answers

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.

like image 86
Itamar Haber Avatar answered Oct 23 '22 18:10

Itamar Haber


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.

like image 22
Ismayil Niftaliyev Avatar answered Oct 23 '22 17:10

Ismayil Niftaliyev