Class DefaultReactivePulsarSenderFactory<T>

java.lang.Object
org.springframework.pulsar.reactive.core.DefaultReactivePulsarSenderFactory<T>
Type Parameters:
T - underlying payload type for the reactive sender.
All Implemented Interfaces:
DisposableBean, Lifecycle, Phased, SmartLifecycle, ReactivePulsarSenderFactory<T>

public final class DefaultReactivePulsarSenderFactory<T> extends Object implements ReactivePulsarSenderFactory<T>
Default implementation of ReactivePulsarSenderFactory.
Author:
Christophe Bornet, Chris Bono
  • Method Details

    • builderFor

      public static <T> DefaultReactivePulsarSenderFactory.Builder<T> builderFor(org.apache.pulsar.reactive.client.api.ReactivePulsarClient reactivePulsarClient)
      Create a builder that uses the specified Reactive pulsar client.
      Type Parameters:
      T - underlying payload type for the reactive sender
      Parameters:
      reactivePulsarClient - the reactive client
      Returns:
      the newly created builder instance
    • builderFor

      public static <T> DefaultReactivePulsarSenderFactory.Builder<T> builderFor(org.apache.pulsar.client.api.PulsarClient pulsarClient)
      Create a builder that adapts the specified pulsar client.
      Type Parameters:
      T - underlying payload type for the reactive sender
      Parameters:
      pulsarClient - the Pulsar client to adapt into a Reactive client
      Returns:
      the newly created builder instance
    • createSender

      public org.apache.pulsar.reactive.client.api.ReactiveMessageSender<T> createSender(org.apache.pulsar.client.api.Schema<T> schema, @Nullable String topic)
      Description copied from interface: ReactivePulsarSenderFactory
      Create a reactive message sender.
      Specified by:
      createSender in interface ReactivePulsarSenderFactory<T>
      Parameters:
      schema - the schema of the messages to be sent
      topic - the topic to send messages to or null to use the default topic
      Returns:
      the reactive message sender
    • createSender

      public org.apache.pulsar.reactive.client.api.ReactiveMessageSender<T> createSender(org.apache.pulsar.client.api.Schema<T> schema, @Nullable String topic, @Nullable ReactiveMessageSenderBuilderCustomizer<T> customizer)
      Description copied from interface: ReactivePulsarSenderFactory
      Create a reactive message sender.
      Specified by:
      createSender in interface ReactivePulsarSenderFactory<T>
      Parameters:
      schema - the schema of the messages to be sent
      topic - the topic to send messages to or null to use the default topic
      customizer - the optional customizer to apply to the reactive message sender builder
      Returns:
      the reactive message sender
    • createSender

      public org.apache.pulsar.reactive.client.api.ReactiveMessageSender<T> createSender(org.apache.pulsar.client.api.Schema<T> schema, @Nullable String topic, @Nullable List<ReactiveMessageSenderBuilderCustomizer<T>> customizers)
      Description copied from interface: ReactivePulsarSenderFactory
      Create a reactive message sender.
      Specified by:
      createSender in interface ReactivePulsarSenderFactory<T>
      Parameters:
      schema - the schema of the messages to be sent
      topic - the topic to send messages to or null to use the default topic
      customizers - the optional list of customizers to apply to the reactive message sender builder
      Returns:
      the reactive message sender
    • getDefaultTopic

      public String getDefaultTopic()
      Description copied from interface: ReactivePulsarSenderFactory
      Get the default topic to use for all created senders.
      Specified by:
      getDefaultTopic in interface ReactivePulsarSenderFactory<T>
      Returns:
      the default topic to use for all created senders or null if no default set.
    • getPhase

      public int getPhase()
      Return the phase that this lifecycle object is supposed to run in.

      This component has a phase that comes after the restartable client (PulsarClientProxy) but before other lifecycle and smart lifecycle components whose phase values are "0" and "max", respectively.

      Specified by:
      getPhase in interface Phased
      Specified by:
      getPhase in interface SmartLifecycle
      Returns:
      a phase that is after the restartable client and before other default components.
    • currentState

      public AtomicReference<org.springframework.pulsar.reactive.core.RestartableComponentSupport.State> currentState()
    • logger

      public LogAccessor logger()
    • doStop

      public void doStop()
    • isRunning

      default boolean isRunning()
      Specified by:
      isRunning in interface Lifecycle
    • start

      default void start()
      Specified by:
      start in interface Lifecycle
    • doStart

      default void doStart()
      Callback invoked during startup - default implementation does nothing.
    • stop

      default void stop()
      Specified by:
      stop in interface Lifecycle
    • destroy

      default void destroy()
      Specified by:
      destroy in interface DisposableBean