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.JedisPubSubSubscribes to the provided Redis channel pattern and dispatches received messages. Method#runmust be called in a new thread.
-
-
Field Summary
Fields Modifier and Type Field Description protected Stringpatternprotected RedisExecutorredisExecutorprotected booleanstopprotected CountDownLatchsubscribedLatch
-
Constructor Summary
Constructors Constructor Description Dispatcher(String pattern)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanawaitSubscribed(long timeout, TimeUnit unit)To be called from the main thread to wait for subscription to be effective.voidclose()To be called from the main thread to stop the subscription.protected voidflush(redis.clients.jedis.Client client)voidonMessage(String channel, byte[] message)voidonPMessage(String pattern, String channel, byte[] message)voidonPSubscribe(String pattern, int subscribedChannels)voidproceed(redis.clients.jedis.Client client, String... channels)voidproceedWithPatterns(redis.clients.jedis.Client client, String... patterns)protected voidprocessBinary(redis.clients.jedis.Client client)voidrun()To be called from a new thread to do the actual Redis subscription and to dispatch messages.protected StringtoString(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:
onPSubscribein classredis.clients.jedis.JedisPubSub
-
onMessage
public void onMessage(String channel, byte[] message)
-
proceed
public void proceed(redis.clients.jedis.Client client, String... channels)- Overrides:
proceedin classredis.clients.jedis.JedisPubSub
-
proceedWithPatterns
public void proceedWithPatterns(redis.clients.jedis.Client client, String... patterns)- Overrides:
proceedWithPatternsin 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)
-
-