Package org.redisson.api
Interface RReliableTopicReactive
- All Superinterfaces:
RExpirableReactive
,RObjectReactive
Reactive interface for 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> reactor.core.publisher.Mono
<String> addListener
(Class<M> type, MessageListener<M> listener) Subscribes to this topic.reactor.core.publisher.Mono
<Integer> Returns amount of subscribers to this topic across all Redisson instances.<M> reactor.core.publisher.Flux
<M> getMessages
(Class<M> type) Returns continues stream of published messages.reactor.core.publisher.Mono
<Long> Publish the message to all subscribers of this topic asynchronously.reactor.core.publisher.Mono
<Void> Removes all listeners attached to this topic instancereactor.core.publisher.Mono
<Void> removeListener
(String... listenerIds) Removes the listener byid
attached to this topic instancereactor.core.publisher.Mono
<Long> size()
Amount of messages stored in Redis Stream object.Methods inherited from interface org.redisson.api.RExpirableReactive
clearExpire, expire, expire, expire, expireAt, expireAt, expireIfGreater, expireIfGreater, expireIfLess, expireIfLess, expireIfNotSet, expireIfNotSet, expireIfSet, expireIfSet, getExpireTime, remainTimeToLive
Methods inherited from interface org.redisson.api.RObjectReactive
addListener, copy, copy, copy, copyAndReplace, copyAndReplace, delete, dump, getCodec, getIdleTime, getName, isExists, migrate, move, removeListener, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, sizeInMemory, touch, unlink
-
Method Details
-
size
reactor.core.publisher.Mono<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.onMessage
method 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 byid
attached to this topic instance- Parameters:
listenerIds
- - listener ids- Returns:
- void
-
removeAllListeners
reactor.core.publisher.Mono<Void> removeAllListeners()Removes all listeners attached to this topic instance -
countSubscribers
reactor.core.publisher.Mono<Integer> countSubscribers()Returns amount of subscribers to this topic across all Redisson instances. Each subscriber may have multiple listeners.- Returns:
- amount of subscribers
-
getMessages
Returns continues stream of published messages.- Type Parameters:
M
- type of message- Parameters:
type
- - type of message to listen- Returns:
- stream of messages
-