How connect two or more subscribers in Jedis(Java Redis)?

532 views Asked by At

I have two subscribers which should connect to different channels. But if I try subscribe them to channels nothing happens. I think that it is some multithreading problem but have not any idea how solve this problem. Is there any example for how to work with multiple subscribers?

1

There are 1 answers

0
Jungtaek Lim On

If it is not under race condition, https://github.com/xetorthio/jedis/pull/998 can help you, and it's scheduled to be released at next version.

Btw, if you don't need to subscribe dynamically, or your channels has same pattern, you don't need to create subscriber for each channel. You can use Jedis.subscribe() and Jedis.psubscribe() to subscribe multiple channel at once.

You can handle messages from onMessage() which gives you channel name and message.