Class RedisPubSubProvider.Dispatcher
- java.lang.Object
-
- redis.clients.jedis.JedisPubSub
-
- org.nuxeo.ecm.core.redis.contribs.RedisPubSubProvider.Dispatcher
-
- Enclosing class:
- RedisPubSubProvider
public class RedisPubSubProvider.Dispatcher extends redis.clients.jedis.JedisPubSub
Subscribes to the provided Redis channel pattern and dispatches received messages. Method#run
must be called in a new thread.
-
-
Field Summary
Fields Modifier and Type Field Description protected String
pattern
protected RedisExecutor
redisExecutor
protected boolean
stop
protected CountDownLatch
subscribedLatch
-
Constructor Summary
Constructors Constructor Description Dispatcher(String pattern)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
awaitSubscribed(long timeout, TimeUnit unit)
To be called from the main thread to wait for subscription to be effective.void
close()
To be called from the main thread to stop the subscription.protected void
flush(redis.clients.jedis.Client client)
void
onMessage(String channel, byte[] message)
void
onPMessage(String pattern, String channel, byte[] message)
void
onPSubscribe(String pattern, int subscribedChannels)
void
proceed(redis.clients.jedis.Client client, String... channels)
void
proceedWithPatterns(redis.clients.jedis.Client client, String... patterns)
protected void
processBinary(redis.clients.jedis.Client client)
void
run()
To be called from a new thread to do the actual Redis subscription and to dispatch messages.protected String
toString(byte[] bytes)
-
-
-
Field Detail
-
redisExecutor
protected RedisExecutor redisExecutor
-
pattern
protected final String pattern
-
subscribedLatch
protected final CountDownLatch subscribedLatch
-
stop
protected volatile boolean stop
-
-
Constructor Detail
-
Dispatcher
public Dispatcher(String pattern)
-
-
Method Detail
-
awaitSubscribed
public boolean awaitSubscribed(long timeout, TimeUnit unit)
To be called from the main thread to wait for subscription to be effective.
-
run
public void run()
To be called from a new thread to do the actual Redis subscription and to dispatch messages.
-
close
public void close()
To be called from the main thread to stop the subscription.
-
onPSubscribe
public void onPSubscribe(String pattern, int subscribedChannels)
- Overrides:
onPSubscribe
in classredis.clients.jedis.JedisPubSub
-
onMessage
public void onMessage(String channel, byte[] message)
-
proceed
public void proceed(redis.clients.jedis.Client client, String... channels)
- Overrides:
proceed
in classredis.clients.jedis.JedisPubSub
-
proceedWithPatterns
public void proceedWithPatterns(redis.clients.jedis.Client client, String... patterns)
- Overrides:
proceedWithPatterns
in classredis.clients.jedis.JedisPubSub
-
flush
protected void flush(redis.clients.jedis.Client client)
-
processBinary
protected void processBinary(redis.clients.jedis.Client client)
-
toString
protected String toString(byte[] bytes)
-
-