Interface PubSubCommands<V>
- Type Parameters:
V
- the class of the exchanged messages.
- All Superinterfaces:
RedisCommands
- All Known Implementing Classes:
BlockingPubSubCommandsImpl
Allows executing Pub/Sub commands.
See the pub/sub documentation.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
A redis subscriber -
Method Summary
Modifier and TypeMethodDescriptionvoid
Publishes a message to a given channelSubscribes to a given channel.Subscribes to a given channel.subscribe
(List<String> channels, BiConsumer<String, V> onMessage, Runnable onEnd, Consumer<Throwable> onException) Same assubscribe(List, Consumer, Runnable, Consumer)
but also receives the channel name.Subscribes to the given channels.subscribe
(List<String> channels, Consumer<V> onMessage, Runnable onEnd, Consumer<Throwable> onException) Subscribes to the given channels.subscribeToPattern
(String pattern, BiConsumer<String, V> onMessage) Same assubscribeToPattern(String, Consumer)
, but instead of receiving only the message payload, it also receives the name of the channel.subscribeToPattern
(String pattern, BiConsumer<String, V> onMessage, Runnable onEnd, Consumer<Throwable> onException) Same assubscribeToPatterns(List, Consumer, Runnable, Consumer)
, but also receives the channel name.subscribeToPattern
(String pattern, Consumer<V> onMessage) Subscribes to a given pattern likechan*l
.subscribeToPattern
(String pattern, Consumer<V> onMessage, Runnable onEnd, Consumer<Throwable> onException) Subscribes to a given pattern likechan*l
.subscribeToPatterns
(List<String> patterns, BiConsumer<String, V> onMessage) Same assubscribeToPatterns(List, Consumer)
, but instead of only receiving the payload, it also receives the channel name.subscribeToPatterns
(List<String> patterns, BiConsumer<String, V> onMessage, Runnable onEnd, Consumer<Throwable> onException) Same assubscribeToPatterns(List, Consumer, Runnable, Consumer)
, but also receive the channel name.subscribeToPatterns
(List<String> patterns, Consumer<V> onMessage) Subscribes to the given patterns likechan*l
.subscribeToPatterns
(List<String> patterns, Consumer<V> onMessage, Runnable onEnd, Consumer<Throwable> onException) Subscribes to the given patterns likechan*l
.Methods inherited from interface io.quarkus.redis.datasource.RedisCommands
getDataSource
-
Method Details
-
publish
Publishes a message to a given channel- Parameters:
channel
- the channelmessage
- the message
-
subscribe
Subscribes to a given channel.- Parameters:
channel
- the channelonMessage
- the message consumer. Be aware that this callback is invoked for each message sent to the given channel, and is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed.- Returns:
- the subscriber object that lets you unsubscribe
-
subscribeToPattern
Subscribes to a given pattern likechan*l
.- Parameters:
pattern
- the patternonMessage
- the message consumer. Be aware that this callback is invoked for each message sent to the channels matching the pattern, and is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed.- Returns:
- the subscriber object that lets you unsubscribe
-
subscribeToPattern
Same assubscribeToPattern(String, Consumer)
, but instead of receiving only the message payload, it also receives the name of the channel.- Parameters:
pattern
- the patternonMessage
- the message consumer. Be aware that this callback is invoked for each message sent to the channels matching the pattern, and is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed. The first parameter is the name of the channel. The second parameter is the payload.- Returns:
- the subscriber object that lets you unsubscribe
-
subscribeToPatterns
Subscribes to the given patterns likechan*l
.- Parameters:
patterns
- the patternsonMessage
- the message consumer. Be aware that this callback is invoked for each message sent to the channels matching the pattern, and is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed.- Returns:
- the subscriber object that lets you unsubscribe
-
subscribeToPatterns
PubSubCommands.RedisSubscriber subscribeToPatterns(List<String> patterns, BiConsumer<String, V> onMessage) Same assubscribeToPatterns(List, Consumer)
, but instead of only receiving the payload, it also receives the channel name.- Parameters:
patterns
- the patternsonMessage
- the message consumer. Be aware that this callback is invoked for each message sent to the channels matching the pattern, and is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed. The first parameter is the channel name. The second one if the payload.- Returns:
- the subscriber object that lets you unsubscribe
-
subscribe
Subscribes to the given channels.- Parameters:
channels
- the channelsonMessage
- the message consumer. Be aware that this callback is invoked for each message sent to the given channels, and is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed.- Returns:
- the subscriber object that lets you unsubscribe
-
subscribe
PubSubCommands.RedisSubscriber subscribe(String channel, Consumer<V> onMessage, Runnable onEnd, Consumer<Throwable> onException) Subscribes to a given channel.- Parameters:
channel
- the channelonMessage
- the message consumer. Be aware that this callback is invoked for each message sent to the given channel, and is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed.onEnd
- the end handler. Be aware that this callback is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed.onException
- the exception handler. Be aware that this callback is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed.- Returns:
- the subscriber object that lets you unsubscribe
-
subscribeToPattern
PubSubCommands.RedisSubscriber subscribeToPattern(String pattern, Consumer<V> onMessage, Runnable onEnd, Consumer<Throwable> onException) Subscribes to a given pattern likechan*l
.- Parameters:
pattern
- the patternonMessage
- the message consumer. Be aware that this callback is invoked for each message sent to the channels matching the pattern, and is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed.onEnd
- the end handler. Be aware that this callback is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed.onException
- the exception handler. Be aware that this callback is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed.- Returns:
- the subscriber object that lets you unsubscribe
-
subscribeToPattern
PubSubCommands.RedisSubscriber subscribeToPattern(String pattern, BiConsumer<String, V> onMessage, Runnable onEnd, Consumer<Throwable> onException) Same assubscribeToPatterns(List, Consumer, Runnable, Consumer)
, but also receives the channel name.- Parameters:
pattern
- the patternonMessage
- the message consumer. Be aware that this callback is invoked for each message sent to the channels matching the pattern, and is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed. The first parameter is the name of the channel. The second parameter is the payload.onEnd
- the end handler. Be aware that this callback is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed.onException
- the exception handler. Be aware that this callback is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed.- Returns:
- the subscriber object that lets you unsubscribe
-
subscribeToPatterns
PubSubCommands.RedisSubscriber subscribeToPatterns(List<String> patterns, Consumer<V> onMessage, Runnable onEnd, Consumer<Throwable> onException) Subscribes to the given patterns likechan*l
.- Parameters:
patterns
- the patternsonMessage
- the message consumer. Be aware that this callback is invoked for each message sent to the channels matching the pattern, and is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed.onEnd
- the end handler. Be aware that this callback is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed.onException
- the exception handler. Be aware that this callback is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed.- Returns:
- the subscriber object that lets you unsubscribe
-
subscribeToPatterns
PubSubCommands.RedisSubscriber subscribeToPatterns(List<String> patterns, BiConsumer<String, V> onMessage, Runnable onEnd, Consumer<Throwable> onException) Same assubscribeToPatterns(List, Consumer, Runnable, Consumer)
, but also receive the channel name.- Parameters:
patterns
- the patternsonMessage
- the message consumer. Be aware that this callback is invoked for each message sent to the channels matching the pattern, and is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed. The first parameter is the name of the channel. The second parameter is the payload.onEnd
- the end handler. Be aware that this callback is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed.onException
- the exception handler. Be aware that this callback is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed.- Returns:
- the subscriber object that lets you unsubscribe
-
subscribe
PubSubCommands.RedisSubscriber subscribe(List<String> channels, Consumer<V> onMessage, Runnable onEnd, Consumer<Throwable> onException) Subscribes to the given channels.- Parameters:
channels
- the channelsonMessage
- the message consumer. Be aware that this callback is invoked for each message sent to the given channels, and is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed.onEnd
- the end handler. Be aware that this callback is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed.onException
- the exception handler. Be aware that this callback is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed.- Returns:
- the subscriber object that lets you unsubscribe
-
subscribe
PubSubCommands.RedisSubscriber subscribe(List<String> channels, BiConsumer<String, V> onMessage, Runnable onEnd, Consumer<Throwable> onException) Same assubscribe(List, Consumer, Runnable, Consumer)
but also receives the channel name.- Parameters:
channels
- the channelsonMessage
- the message consumer. Be aware that this callback is invoked for each message sent to the given channels, and is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed. The first parameter is the name of the channel. The second parameter is the payload.onEnd
- the end handler. Be aware that this callback is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed.onException
- the exception handler. Be aware that this callback is invoked on the I/O thread. So, you must not block. Offload to a separate thread if needed.- Returns:
- the subscriber object that lets you unsubscribe
-