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 Details

    • RedisPubSubPublisher

      public RedisPubSubPublisher(io.micronaut.context.BeanLocator beanLocator, RedisMessageBodyHandler messageBodyHandler)
      Parameters:
      beanLocator - The bean locator
      messageBodyHandler - The message body handler
  • Method Details

    • publish

      public long publish(String channel, Object body)
      Publish a message to the default Redis connection.
      Parameters:
      channel - The channel name
      body - The message body
      Returns:
      The Redis publish subscriber count
    • publishOnConnection

      public long publishOnConnection(@Nullable String connectionName, String channel, Object body)
      Publish a message to a named Redis connection.
      Parameters:
      connectionName - The named connection
      channel - The channel name
      body - 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.core.annotation.AnnotationMetadata annotationMetadata, Object body)
      Publish a message to a named Redis connection.
      Parameters:
      connectionName - The named connection
      channel - The channel name
      argument - The body argument
      annotationMetadata - The body annotation metadata
      body - 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 connection
      channel - The channel name
      argument - The body argument
      mediaType - The media type
      body - The message body
      Returns:
      The Redis publish subscriber count
    • close

      @PreDestroy public void close()
      Specified by:
      close in interface AutoCloseable