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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Builder forDefaultReactivePulsarSenderFactory
. -
Field Summary
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> DefaultReactivePulsarSenderFactory.Builder<T>
builderFor
(org.apache.pulsar.client.api.PulsarClient pulsarClient) Create a builder that adapts the specified pulsar client.static <T> DefaultReactivePulsarSenderFactory.Builder<T>
builderFor
(org.apache.pulsar.reactive.client.api.ReactivePulsarClient reactivePulsarClient) Create a builder that uses the specified Reactive pulsar client.org.apache.pulsar.reactive.client.api.ReactiveMessageSender<T>
createSender
(org.apache.pulsar.client.api.Schema<T> schema, String topic) Create a reactive message sender.org.apache.pulsar.reactive.client.api.ReactiveMessageSender<T>
createSender
(org.apache.pulsar.client.api.Schema<T> schema, String topic, List<ReactiveMessageSenderBuilderCustomizer<T>> customizers) Create a reactive message sender.org.apache.pulsar.reactive.client.api.ReactiveMessageSender<T>
createSender
(org.apache.pulsar.client.api.Schema<T> schema, String topic, ReactiveMessageSenderBuilderCustomizer<T> customizer) Create a reactive message sender.AtomicReference<org.springframework.pulsar.reactive.core.RestartableComponentSupport.State>
default void
destroy()
default void
doStart()
Callback invoked during startup - default implementation does nothing.void
doStop()
Get the default topic to use for all created senders.int
getPhase()
Return the phase that this lifecycle object is supposed to run in.default boolean
logger()
default void
start()
default void
stop()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.context.SmartLifecycle
isAutoStartup, stop
-
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 interfaceReactivePulsarSenderFactory<T>
- Parameters:
schema
- the schema of the messages to be senttopic
- the topic to send messages to ornull
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 interfaceReactivePulsarSenderFactory<T>
- Parameters:
schema
- the schema of the messages to be senttopic
- the topic to send messages to ornull
to use the default topiccustomizer
- 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 interfaceReactivePulsarSenderFactory<T>
- Parameters:
schema
- the schema of the messages to be senttopic
- the topic to send messages to ornull
to use the default topiccustomizers
- the optional list of customizers to apply to the reactive message sender builder- Returns:
- the reactive message sender
-
getDefaultTopic
Description copied from interface:ReactivePulsarSenderFactory
Get the default topic to use for all created senders.- Specified by:
getDefaultTopic
in interfaceReactivePulsarSenderFactory<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 interfacePhased
- Specified by:
getPhase
in interfaceSmartLifecycle
- 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
-
doStop
public void doStop() -
isRunning
default boolean isRunning() -
start
default void start() -
doStart
default void doStart()Callback invoked during startup - default implementation does nothing. -
stop
default void stop() -
destroy
default void destroy()- Specified by:
destroy
in interfaceDisposableBean
-