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

    Fields
    Modifier and Type
    Field
    Description
    protected final io.micronaut.context.event.ApplicationEventPublisher<ProducerSubscriptionFailedEvent>
     
    protected final io.micronaut.context.BeanContext
     
    protected final io.micronaut.core.convert.ConversionService
     
    protected final Map<String,org.apache.pulsar.client.api.Producer<?>>
     
    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

    Constructors
    Constructor
    Description
    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.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    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.
    Map<String,org.apache.pulsar.client.api.Producer<?>>
    Get all managed producers.
    intercept(io.micronaut.aop.MethodInvocationContext<Object,Object> context)
     

    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

      protected final Map<String,org.apache.pulsar.client.api.Producer<?>> producers
    • pulsarClient

      protected final org.apache.pulsar.client.api.PulsarClient pulsarClient
    • simpleSchemaResolver

      protected final DefaultSchemaHandler 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 bean
      simpleSchemaResolver - Schema resolver
      beanContext - Micronaut bean context
      applicationEventPublisher - Event publisher for reporting failed subscriptions
      conversionService - Micronaut conversion service
  • Method Details

    • intercept

      public Object intercept(io.micronaut.aop.MethodInvocationContext<Object,Object> context)
      Specified by:
      intercept in interface io.micronaut.aop.MethodInterceptor<Object,Object>
    • 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 with PulsarProducer
      annotationValue - PulsarProducer value
      Returns:
      existing producer if exists; otherwise create a new one
    • close

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

      public Map<String,org.apache.pulsar.client.api.Producer<?>> getProducers()
      Description copied from interface: PulsarProducerRegistry
      Get all managed producers.
      Specified by:
      getProducers in interface PulsarProducerRegistry
      Returns:
      List of managed producers.
    • getProducer

      public org.apache.pulsar.client.api.Producer<?> getProducer(@NonNull @NonNull String id)
      Description copied from interface: PulsarProducerRegistry
      Get single managed producer by its name.
      Specified by:
      getProducer in interface PulsarProducerRegistry
      Parameters:
      id - unique identifier
      Returns:
      Pulsar producer by given name
    • getProducerIds

      public Set<String> getProducerIds()
      Description copied from interface: PulsarProducerRegistry
      Get all managed producer identifiers.
      Specified by:
      getProducerIds in interface PulsarProducerRegistry
      Returns:
      List of producer names representing their identifiers in registry.