Package com.github.ddth.pubsub.impl
Class RedisPubSubHub<ID,DATA>
- java.lang.Object
-
- com.github.ddth.pubsub.impl.AbstractPubSubHub<ID,DATA>
-
- com.github.ddth.pubsub.impl.BaseRedisPubSubHub<ID,DATA>
-
- com.github.ddth.pubsub.impl.RedisPubSubHub<ID,DATA>
-
- All Implemented Interfaces:
IPubSubHub<ID,DATA>
,AutoCloseable
- Direct Known Subclasses:
UniversalRedisPubSubHub
,UniversalRedisPubSubHub
public class RedisPubSubHub<ID,DATA> extends BaseRedisPubSubHub<ID,DATA>
Redis implementation ofIPubSubHub
.- Since:
- 0.7.0
- Author:
- Thanh Ba Nguyen
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_HOST_AND_PORT
-
Fields inherited from class com.github.ddth.pubsub.impl.BaseRedisPubSubHub
DEFAULT_PASSWORD, myOwnRedis
-
-
Constructor Summary
Constructors Constructor Description RedisPubSubHub()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected com.github.ddth.commons.redis.JedisConnector
buildJedisConnector()
Build aJedisConnector
instance for my own use.void
destroy()
Destroy method.String
getRedisHostAndPort()
Redis' host and port scheme (formathost:port
).RedisPubSubHub<ID,DATA>
init()
Init method.boolean
isReady()
Returntrue
if this hub is ready for subscribing.boolean
publish(String channel, IMessage<ID,DATA> msg)
Publish a message to a channel.RedisPubSubHub<ID,DATA>
setRedisHostAndPort(String redisHostAndPort)
Redis' host and port scheme (formathost:port
).void
subscribe(String channel, ISubscriber<ID,DATA> subscriber)
Subscribe to a channel for messages.void
unsubscribe(String channel, ISubscriber<ID,DATA> subscriber)
Unsubscribe from a channel.-
Methods inherited from class com.github.ddth.pubsub.impl.BaseRedisPubSubHub
getJedisConnector, getRedisPassword, setJedisConnector, setJedisConnector, setRedisPassword
-
Methods inherited from class com.github.ddth.pubsub.impl.AbstractPubSubHub
close, createMessage, createMessage, createMessage, deserialize, deserialize, getMessageFactory, getSerDeser, serialize, setMessageFactory, setSerDeser
-
-
-
-
Field Detail
-
DEFAULT_HOST_AND_PORT
public static final String DEFAULT_HOST_AND_PORT
- See Also:
- Constant Field Values
-
-
Method Detail
-
getRedisHostAndPort
public String getRedisHostAndPort()
Redis' host and port scheme (formathost:port
).- Returns:
-
setRedisHostAndPort
public RedisPubSubHub<ID,DATA> setRedisHostAndPort(String redisHostAndPort)
Redis' host and port scheme (formathost:port
).- Parameters:
redisHostAndPort
-- Returns:
-
isReady
public boolean isReady()
Returntrue
if this hub is ready for subscribing.- Returns:
-
buildJedisConnector
protected com.github.ddth.commons.redis.JedisConnector buildJedisConnector()
Build aJedisConnector
instance for my own use.- Specified by:
buildJedisConnector
in classBaseRedisPubSubHub<ID,DATA>
- Returns:
-
init
public RedisPubSubHub<ID,DATA> init()
Init method.- Overrides:
init
in classBaseRedisPubSubHub<ID,DATA>
- Returns:
-
destroy
public void destroy()
Destroy method.- Overrides:
destroy
in classBaseRedisPubSubHub<ID,DATA>
-
publish
public boolean publish(String channel, IMessage<ID,DATA> msg)
Publish a message to a channel.- Returns:
-
subscribe
public void subscribe(String channel, ISubscriber<ID,DATA> subscriber)
Subscribe to a channel for messages.
-
unsubscribe
public void unsubscribe(String channel, ISubscriber<ID,DATA> subscriber)
Unsubscribe from a channel.
-
-