Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2204

How to keep listening for messages with Vertx and Redis?

$
0
0

I have a Listener like this:

public class Listener extends AbstractVerticle {    public static void main(String[] args) {        Launcher.executeCommand("run", Listener.class.getName());    }    @Override    public void start() {        RedisOptions config = new RedisOptions()                .setHost("127.0.0.1");        RedisClient redis = RedisClient.create(vertx, config);        redis.blpop("myKey", 3500, System.out::println);    }}

And when a message is received, it is successfully printed on console, but no other message can be received anymore. And if I run the blpop inside a while(true) I get an Exception for blocking the thread.

How can I permanently listen for message with Vertx and Redis?

What I really need to archive is some kind of Round Robin with many "listeners" but only one getting the message at the time. I mean, one to many publishers to a specific channel, and one to many subscribers, but when a message us published just one subscriber gets the message.


Viewing all articles
Browse latest Browse all 2204

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>