Package io.micronaut.pulsar.intercept
Class PulsarProducerAdvice
java.lang.Object
io.micronaut.pulsar.intercept.PulsarProducerAdvice
- All Implemented Interfaces:
io.micronaut.aop.Interceptor<Object,
,Object> io.micronaut.aop.MethodInterceptor<Object,
,Object> io.micronaut.core.order.Ordered
,PulsarProducerRegistry
,AutoCloseable
- Direct Known Subclasses:
PulsarMultitenantProducerAdvice
@InterceptorBean(PulsarProducerClient.class)
public class PulsarProducerAdvice
extends Object
implements io.micronaut.aop.MethodInterceptor<Object,Object>, AutoCloseable, PulsarProducerRegistry
Intercepting pulsar
Producer
methods. It can be used for creating implementation of interface methods or
just to add producer behaviour to existing methods.- Since:
- 1.0
- Author:
- Haris Secic
-
Field Summary
Modifier and TypeFieldDescriptionprotected final io.micronaut.context.event.ApplicationEventPublisher<ProducerSubscriptionFailedEvent>
protected final io.micronaut.context.BeanContext
protected final io.micronaut.core.convert.ConversionService
protected final org.apache.pulsar.client.api.PulsarClient
protected final DefaultSchemaHandler
Fields inherited from interface io.micronaut.aop.Interceptor
ARGUMENT, CACHEABLE_LAZY_TARGET, HOTSWAP, LAZY, PROXY_TARGET
Fields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorDescriptionPulsarProducerAdvice
(org.apache.pulsar.client.api.PulsarClient pulsarClient, DefaultSchemaHandler simpleSchemaResolver, io.micronaut.context.BeanContext beanContext, io.micronaut.context.event.ApplicationEventPublisher<ProducerSubscriptionFailedEvent> applicationEventPublisher, io.micronaut.core.convert.ConversionService conversionService) Constructor for instantiating Pulsar producer advice for intercepting producer methods. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
protected org.apache.pulsar.client.api.Producer<?>
getOrCreateProducer
(io.micronaut.inject.ExecutableMethod<?, ?> method, io.micronaut.core.annotation.AnnotationValue<PulsarProducer> annotationValue) Fetch existing producer or generate a new one via factory if missing.org.apache.pulsar.client.api.Producer<?>
getProducer
(@NonNull String id) Get single managed producer by its name.Get all managed producer identifiers.Get all managed producers.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.aop.MethodInterceptor
intercept
Methods inherited from interface io.micronaut.core.order.Ordered
getOrder
-
Field Details
-
producers
-
pulsarClient
protected final org.apache.pulsar.client.api.PulsarClient pulsarClient -
simpleSchemaResolver
-
beanContext
protected final io.micronaut.context.BeanContext beanContext -
applicationEventPublisher
protected final io.micronaut.context.event.ApplicationEventPublisher<ProducerSubscriptionFailedEvent> applicationEventPublisher -
conversionService
protected final io.micronaut.core.convert.ConversionService conversionService
-
-
Constructor Details
-
PulsarProducerAdvice
public PulsarProducerAdvice(org.apache.pulsar.client.api.PulsarClient pulsarClient, DefaultSchemaHandler simpleSchemaResolver, io.micronaut.context.BeanContext beanContext, io.micronaut.context.event.ApplicationEventPublisher<ProducerSubscriptionFailedEvent> applicationEventPublisher, io.micronaut.core.convert.ConversionService conversionService) Constructor for instantiating Pulsar producer advice for intercepting producer methods.- Parameters:
pulsarClient
- Apache Pulsar client beansimpleSchemaResolver
- Schema resolverbeanContext
- Micronaut bean contextapplicationEventPublisher
- Event publisher for reporting failed subscriptionsconversionService
- Micronaut conversion service
-
-
Method Details
-
intercept
-
getOrCreateProducer
protected org.apache.pulsar.client.api.Producer<?> getOrCreateProducer(io.micronaut.inject.ExecutableMethod<?, ?> method, io.micronaut.core.annotation.AnnotationValue<PulsarProducer> annotationValue) Fetch existing producer or generate a new one via factory if missing.- Parameters:
method
- method annotated withPulsarProducer
annotationValue
-PulsarProducer
value- Returns:
- existing producer if exists; otherwise create a new one
-
close
@PreDestroy public void close()- Specified by:
close
in interfaceAutoCloseable
-
getProducers
Description copied from interface:PulsarProducerRegistry
Get all managed producers.- Specified by:
getProducers
in interfacePulsarProducerRegistry
- Returns:
- List of managed producers.
-
getProducer
Description copied from interface:PulsarProducerRegistry
Get single managed producer by its name.- Specified by:
getProducer
in interfacePulsarProducerRegistry
- Parameters:
id
- unique identifier- Returns:
- Pulsar producer by given name
-
getProducerIds
Description copied from interface:PulsarProducerRegistry
Get all managed producer identifiers.- Specified by:
getProducerIds
in interfacePulsarProducerRegistry
- Returns:
- List of producer names representing their identifiers in registry.
-