Package org.springframework.pulsar.core
Interface PulsarProducerFactory<T>
- Type Parameters:
T- producer payload type
- All Known Implementing Classes:
CachingPulsarProducerFactory,DefaultPulsarProducerFactory
public interface PulsarProducerFactory<T>
The strategy to create a
Producer instance(s).-
Method Summary
Modifier and TypeMethodDescriptionorg.apache.pulsar.client.api.Producer<T>createProducer(org.apache.pulsar.client.api.Schema<T> schema, String topic) Create a producer.org.apache.pulsar.client.api.Producer<T>createProducer(org.apache.pulsar.client.api.Schema<T> schema, String topic, Collection<String> encryptionKeys, List<ProducerBuilderCustomizer<T>> customizers) Create a producer.org.apache.pulsar.client.api.Producer<T>createProducer(org.apache.pulsar.client.api.Schema<T> schema, String topic, ProducerBuilderCustomizer<T> customizer) Create a producer.Get the default topic to use for all created producers.org.apache.pulsar.client.api.PulsarClientGet the Pulsar client that the producer factory uses to create producers.
-
Method Details
-
getPulsarClient
org.apache.pulsar.client.api.PulsarClient getPulsarClient()Get the Pulsar client that the producer factory uses to create producers.- Returns:
- the Pulsar client that the producer factory uses to create producers
- Since:
- 1.1.0
-
createProducer
org.apache.pulsar.client.api.Producer<T> createProducer(org.apache.pulsar.client.api.Schema<T> schema, @Nullable String topic) Create a producer.- Parameters:
schema- the schema of the messages to be senttopic- the topic the producer will send messages to ornullto use the default topic- Returns:
- the producer
- Throws:
PulsarException- if any error occurs
-
createProducer
org.apache.pulsar.client.api.Producer<T> createProducer(org.apache.pulsar.client.api.Schema<T> schema, @Nullable String topic, @Nullable ProducerBuilderCustomizer<T> customizer) Create a producer.- Parameters:
schema- the schema of the messages to be senttopic- the topic the producer will send messages to ornullto use the default topiccustomizer- the optional customizer to apply to the producer builder- Returns:
- the producer
- Throws:
PulsarException- if any error occurs
-
createProducer
org.apache.pulsar.client.api.Producer<T> createProducer(org.apache.pulsar.client.api.Schema<T> schema, @Nullable String topic, @Nullable Collection<String> encryptionKeys, @Nullable List<ProducerBuilderCustomizer<T>> customizers) Create a producer.- Parameters:
schema- the schema of the messages to be senttopic- the topic the producer will send messages to ornullto use the default topicencryptionKeys- the encryption keys used by the producer, replacing the default encryption keys ornullto use the default encryption keys. Beware thatProducerBuilderonly hasProducerBuilder.addEncryptionKey(java.lang.String)and doesn't have methods to replace the encryption keys.customizers- the optional list of customizers to apply to the producer builder- Returns:
- the producer
- Throws:
PulsarException- if any error occurs
-
getDefaultTopic
Get the default topic to use for all created producers.- Returns:
- the default topic to use for all created producers or null if no default set
-