Class RedisPubSubPublisher
java.lang.Object
io.micronaut.configuration.lettuce.pubsub.RedisPubSubPublisher
- All Implemented Interfaces:
AutoCloseable
@Singleton
@Requires(beans=AbstractRedisConfiguration.class)
public class RedisPubSubPublisher
extends Object
implements AutoCloseable
Publishes messages to Redis Pub/Sub channels.
- Since:
- 7.0
- Author:
- Graeme Rocher
-
Constructor Summary
ConstructorsConstructorDescriptionRedisPubSubPublisher(io.micronaut.context.BeanLocator beanLocator, RedisMessageBodyHandler messageBodyHandler) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()longPublish a message to the default Redis connection.longpublishOnConnection(@Nullable String connectionName, String channel, io.micronaut.core.type.Argument<?> argument, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, Object body) Publish a message to a named Redis connection.longpublishOnConnection(@Nullable String connectionName, String channel, io.micronaut.core.type.Argument<?> argument, io.micronaut.http.MediaType mediaType, Object body) Publish a message using an explicit media type.longpublishOnConnection(@Nullable String connectionName, String channel, Object body) Publish a message to a named Redis connection.
-
Constructor Details
-
RedisPubSubPublisher
public RedisPubSubPublisher(io.micronaut.context.BeanLocator beanLocator, RedisMessageBodyHandler messageBodyHandler) - Parameters:
beanLocator- The bean locatormessageBodyHandler- The message body handler
-
-
Method Details
-
publish
-
publishOnConnection
-
publishOnConnection
public long publishOnConnection(@Nullable String connectionName, String channel, io.micronaut.core.type.Argument<?> argument, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, Object body) Publish a message to a named Redis connection.- Parameters:
connectionName- The named connectionchannel- The channel nameargument- The body argumentannotationMetadata- The body annotation metadatabody- The message body- Returns:
- The Redis publish subscriber count
-
publishOnConnection
public long publishOnConnection(@Nullable String connectionName, String channel, io.micronaut.core.type.Argument<?> argument, io.micronaut.http.MediaType mediaType, Object body) Publish a message using an explicit media type.- Parameters:
connectionName- The named connectionchannel- The channel nameargument- The body argumentmediaType- The media typebody- The message body- Returns:
- The Redis publish subscriber count
-
close
@PreDestroy public void close()- Specified by:
closein interfaceAutoCloseable
-