hi there,
what is the correct way to have a connection which can both publish & listen to messages ? do i need to create 2 StatefulRedisPubSubConnection connection ? (1 for listening & 1 for publishing)
this code doesnt work for me , i got
"com.lambdaworks.redis.RedisCommandExecutionException: ERR only (P)SUBSCRIBE / (P)UNSUBSCRIBE / PING / QUIT allowed in this context" when try to publish.
i'm on Lettuce 4.0.2
thanx
RedisClient client = RedisClient.create(server);
//connect
StatefulRedisPubSubConnection<String, String> listener = client.connectPubSub();
//listener
listener.addListener(new RedisPubSubAdapter<String, String>(){
@Override
public void message(String channel, String message) {
System.out.println("got msg:" + message + " on channel " + channel);
}
});
//subscribe
listener.async().subscribe(addr);
//send msg
listener.sync().publish(addr, msg);