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 Summary
ConstructorDescriptionJetStreamPushConsumerAdvice
(io.micronaut.context.BeanContext beanContext, NatsBinderRegistry binderRegistry, JetStreamListenerExceptionHandler exceptionHandler, io.micronaut.runtime.ApplicationConfiguration applicationConfiguration) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
io.nats.client.JetStreamSubscription
newSubscription
(String subject, io.nats.client.PushSubscribeOptions pushSubscribeOptions, String queue) Create a new push consumer with the default connection.io.nats.client.JetStreamSubscription
newSubscription
(String connectionName, String subject, io.nats.client.PushSubscribeOptions pushSubscribeOptions, String queue) Create a new push consumer from the given connection name.void
process
(io.micronaut.inject.BeanDefinition<?> beanDefinition, io.micronaut.inject.ExecutableMethod<?, ?> method)
-
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 contextbinderRegistry
- The registry to bind arguments to the methodexceptionHandler
- The exception handler to use if the consumer isn't a handlerapplicationConfiguration
- The application configuration
-
-
Method Details
-
process
public void process(io.micronaut.inject.BeanDefinition<?> beanDefinition, io.micronaut.inject.ExecutableMethod<?, ?> method) - Specified by:
process
in interfaceio.micronaut.context.processor.AnnotationProcessor<PushConsumer,
io.micronaut.inject.ExecutableMethod<?, ?>> - Specified by:
process
in interfaceio.micronaut.context.processor.ExecutableMethodProcessor<PushConsumer>
-
close
@PreDestroy public void close()- Specified by:
close
in interfaceAutoCloseable
-
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 interfacePushConsumerRegistry
- Parameters:
subject
-String
pushSubscribeOptions
-PushSubscribeOptions
queue
-String
optional- Returns:
- subscription
JetStreamSubscription
- Throws:
io.nats.client.JetStreamApiException
- in case of a jetstream errorIOException
- 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 interfacePushConsumerRegistry
- Parameters:
connectionName
-String
subject
-String
pushSubscribeOptions
-PushSubscribeOptions
queue
-String
optional- Returns:
- subscription
JetStreamSubscription
- Throws:
io.nats.client.JetStreamApiException
- in case of a jetstream errorIOException
- in case of a connection error
-