Package org.redisson.api
Interface RReliableTopic
- All Superinterfaces:
RExpirable,RExpirableAsync,RObject,RObjectAsync,RReliableTopicAsync
- All Known Implementing Classes:
RedissonReliableTopic
Reliable topic based on Redis Stream object.
Dedicated Redis connection is allocated per instance (subscriber) of this object. Messages are delivered to all listeners attached to the same Redis setup.
Requires Redis 5.0.0 and higher.
- Author:
- Nikita Koksharov
-
Method Summary
Modifier and TypeMethodDescription<M> StringaddListener(Class<M> type, MessageListener<M> listener) Subscribes to this topic.intReturns amount of registered listeners to this topic instanceintReturns amount of subscribers to this topic across all Redisson instances.longPublish the message to all subscribers of this topic asynchronously.voidRemoves all listeners attached to this topic instancevoidremoveListener(String... listenerIds) Removes the listener byidattached to this topic instancelongsize()Amount of messages stored in Redis Stream object.Methods inherited from interface org.redisson.api.RExpirable
clearExpire, expire, expire, expire, expireAt, expireAt, expireIfGreater, expireIfGreater, expireIfLess, expireIfLess, expireIfNotSet, expireIfNotSet, expireIfSet, expireIfSet, getExpireTime, remainTimeToLiveMethods inherited from interface org.redisson.api.RExpirableAsync
clearExpireAsync, expireAsync, expireAsync, expireAsync, expireAtAsync, expireAtAsync, expireIfGreaterAsync, expireIfGreaterAsync, expireIfLessAsync, expireIfLessAsync, expireIfNotSetAsync, expireIfNotSetAsync, expireIfSetAsync, expireIfSetAsync, getExpireTimeAsync, remainTimeToLiveAsyncMethods inherited from interface org.redisson.api.RObject
addListener, copy, copy, copy, copyAndReplace, copyAndReplace, delete, dump, getCodec, getIdleTime, getName, isExists, migrate, move, removeListener, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, sizeInMemory, touch, unlinkMethods inherited from interface org.redisson.api.RObjectAsync
addListenerAsync, copyAndReplaceAsync, copyAndReplaceAsync, copyAsync, copyAsync, copyAsync, deleteAsync, dumpAsync, getIdleTimeAsync, isExistsAsync, migrateAsync, moveAsync, removeListenerAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemoryAsync, touchAsync, unlinkAsyncMethods inherited from interface org.redisson.api.RReliableTopicAsync
addListenerAsync, countSubscribersAsync, publishAsync, removeAllListenersAsync, removeListenerAsync, sizeAsync
-
Method Details
-
size
long size()Amount of messages stored in Redis Stream object.- Returns:
- amount of messages
-
publish
Publish the message to all subscribers of this topic asynchronously. Each subscriber may have multiple listeners.- Parameters:
message- to send- Returns:
- number of subscribers that received the message
-
addListener
Subscribes to this topic.MessageListener.onMessagemethod is called when any message is published on this topic.Though messages broadcasted across all topic instances, listener is attached to this topic instance.
Watchdog is started when listener was registered.
- Type Parameters:
M- - type of message- Parameters:
type- - type of messagelistener- for messages- Returns:
- id of listener attached to this topic instance
- See Also:
-
removeListener
Removes the listener byidattached to this topic instance- Parameters:
listenerIds- - listener ids
-
removeAllListeners
void removeAllListeners()Removes all listeners attached to this topic instance -
countListeners
int countListeners()Returns amount of registered listeners to this topic instance- Returns:
- amount of listeners
-
countSubscribers
int countSubscribers()Returns amount of subscribers to this topic across all Redisson instances. Each subscriber may have multiple listeners.- Returns:
- amount of subscribers
-