Class JetStreamPushConsumerAdvice

java.lang.Object
io.micronaut.nats.jetstream.intercept.JetStreamPushConsumerAdvice
All Implemented Interfaces:
io.micronaut.context.processor.AnnotationProcessor<PushConsumer,io.micronaut.inject.ExecutableMethod<?,?>>, io.micronaut.context.processor.ExecutableMethodProcessor<PushConsumer>, PushConsumerRegistry, AutoCloseable

@Singleton @Bean(preDestroy="close") public class JetStreamPushConsumerAdvice extends Object implements io.micronaut.context.processor.ExecutableMethodProcessor<PushConsumer>, AutoCloseable, PushConsumerRegistry
An ExecutableMethodProcessor that will process all beans annotated with JetStreamListener. It creates and subscribes the relevant methods as consumers to Jetstream streams.
Since:
4.0.0
Author:
Joachim Grimm
  • Constructor Details

    • JetStreamPushConsumerAdvice

      public JetStreamPushConsumerAdvice(io.micronaut.context.BeanContext beanContext, NatsBinderRegistry binderRegistry, JetStreamListenerExceptionHandler exceptionHandler, io.micronaut.runtime.ApplicationConfiguration applicationConfiguration)
      Default constructor.
      Parameters:
      beanContext - The bean context
      binderRegistry - The registry to bind arguments to the method
      exceptionHandler - The exception handler to use if the consumer isn't a handler
      applicationConfiguration - The application configuration
  • Method Details

    • process

      public void process(io.micronaut.inject.BeanDefinition<?> beanDefinition, io.micronaut.inject.ExecutableMethod<?,?> method)
      Specified by:
      process in interface io.micronaut.context.processor.AnnotationProcessor<PushConsumer,io.micronaut.inject.ExecutableMethod<?,?>>
      Specified by:
      process in interface io.micronaut.context.processor.ExecutableMethodProcessor<PushConsumer>
    • close

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

      public io.nats.client.JetStreamSubscription newSubscription(String subject, io.nats.client.PushSubscribeOptions pushSubscribeOptions, String queue) throws io.nats.client.JetStreamApiException, IOException
      Description copied from interface: PushConsumerRegistry
      Create a new push consumer with the default connection.
      Specified by:
      newSubscription in interface PushConsumerRegistry
      Parameters:
      subject - String
      pushSubscribeOptions - PushSubscribeOptions
      queue - String optional
      Returns:
      subscription JetStreamSubscription
      Throws:
      io.nats.client.JetStreamApiException - in case of a jetstream error
      IOException - in case of a connection error
    • newSubscription

      public io.nats.client.JetStreamSubscription newSubscription(String connectionName, String subject, io.nats.client.PushSubscribeOptions pushSubscribeOptions, String queue) throws io.nats.client.JetStreamApiException, IOException
      Description copied from interface: PushConsumerRegistry
      Create a new push consumer from the given connection name.
      Specified by:
      newSubscription in interface PushConsumerRegistry
      Parameters:
      connectionName - String
      subject - String
      pushSubscribeOptions - PushSubscribeOptions
      queue - String optional
      Returns:
      subscription JetStreamSubscription
      Throws:
      io.nats.client.JetStreamApiException - in case of a jetstream error
      IOException - in case of a connection error