Package com.reve.balancemanager.pubsub
Class PubSubSubscriber
java.lang.Object
redis.clients.jedis.JedisPubSub
com.reve.balancemanager.pubsub.PubSubSubscriber
- All Implemented Interfaces:
Runnable
Subscriber class to subscribe and listen to messages in Redis cluster pubsub
-
Constructor Summary
ConstructorsConstructorDescriptionPubSubSubscriber(BalanceManager balanceManager, redis.clients.jedis.JedisCluster jedisCluster, String[] channels) Create an instance ofRunnableto subscribe on the given channels. -
Method Summary
Modifier and TypeMethodDescriptionvoidProcess the message received from the given channel.voidonSubscribe(String channel, int subscribedChannels) Process on subscribe successful event.voidonUnsubscribe(String channel, int subscribedChannels) Process on subscribe successful event.voidrun()Thread run method.Methods inherited from class redis.clients.jedis.JedisPubSub
getSubscribedChannels, isSubscribed, onPMessage, onPong, onPSubscribe, onPUnsubscribe, ping, ping, proceed, proceedWithPatterns, psubscribe, punsubscribe, punsubscribe, subscribe, unsubscribe, unsubscribe
-
Constructor Details
-
PubSubSubscriber
public PubSubSubscriber(BalanceManager balanceManager, redis.clients.jedis.JedisCluster jedisCluster, String[] channels) Create an instance ofRunnableto subscribe on the given channels.- Parameters:
balanceManager- Instance ofBalanceManagerwho will process the received messages from the subscribed channels.jedisCluster- Connection ofJedisClusterto subscribe the redis channels.channels- The redis channels to whom thisPubSubSubscriberwill subscribe.
-
-
Method Details
-
run
public void run()Thread run method. -
onMessage
Process the message received from the given channel.- Overrides:
onMessagein classredis.clients.jedis.JedisPubSub- Parameters:
channel- The channel, where the message is received.message- The received message.
-
onSubscribe
Process on subscribe successful event. Whenever a subscription is successful, this method will be called, to notify the event.- Overrides:
onSubscribein classredis.clients.jedis.JedisPubSub- Parameters:
channel- The channel, where subscription is successful.subscribedChannels- Total number of channels thisJedisPubSubinstance has successfully subscribed so far.
-
onUnsubscribe
Process on subscribe successful event. Whenever a subscription is successful, this method will be called, to notify the event.- Overrides:
onUnsubscribein classredis.clients.jedis.JedisPubSub- Parameters:
channel- The channel, where un-subscription is successful.subscribedChannels- Total number of channels thisJedisPubSubinstance has successfully subscribed so far.
-