Package org.springframework.pulsar.core
Class DefaultPulsarProducerFactory<T>
java.lang.Object
org.springframework.pulsar.core.DefaultPulsarProducerFactory<T>
- Type Parameters:
T- producer type.
- All Implemented Interfaces:
PulsarProducerFactory<T>
- Direct Known Subclasses:
CachingPulsarProducerFactory
Default implementation of
PulsarProducerFactory.- Author:
- Soby Chacko, Chris Bono, Alexander Preuß, Christophe Bornet
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultPulsarProducerFactory(org.apache.pulsar.client.api.PulsarClient pulsarClient, Map<String, Object> config) DefaultPulsarProducerFactory(org.apache.pulsar.client.api.PulsarClient pulsarClient, Map<String, Object> config, TopicResolver topicResolver) -
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.protected org.apache.pulsar.client.api.Producer<T>doCreateProducer(org.apache.pulsar.client.api.Schema<T> schema, String topic, Collection<String> encryptionKeys, List<ProducerBuilderCustomizer<T>> customizers) Create the actual producer.Return a map of configuration options to use when creating producers.protected StringresolveTopicName(String userSpecifiedTopic)
-
Constructor Details
-
DefaultPulsarProducerFactory
-
DefaultPulsarProducerFactory
public DefaultPulsarProducerFactory(org.apache.pulsar.client.api.PulsarClient pulsarClient, Map<String, Object> config, TopicResolver topicResolver)
-
-
Method Details
-
createProducer
public org.apache.pulsar.client.api.Producer<T> createProducer(org.apache.pulsar.client.api.Schema<T> schema, @Nullable String topic) throws org.apache.pulsar.client.api.PulsarClientException Description copied from interface:PulsarProducerFactoryCreate a producer.- Specified by:
createProducerin interfacePulsarProducerFactory<T>- 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:
org.apache.pulsar.client.api.PulsarClientException- if any error occurs
-
createProducer
public org.apache.pulsar.client.api.Producer<T> createProducer(org.apache.pulsar.client.api.Schema<T> schema, @Nullable String topic, @Nullable ProducerBuilderCustomizer<T> customizer) throws org.apache.pulsar.client.api.PulsarClientException Description copied from interface:PulsarProducerFactoryCreate a producer.- Specified by:
createProducerin interfacePulsarProducerFactory<T>- 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:
org.apache.pulsar.client.api.PulsarClientException- if any error occurs
-
createProducer
public 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) throws org.apache.pulsar.client.api.PulsarClientException Description copied from interface:PulsarProducerFactoryCreate a producer.- Specified by:
createProducerin interfacePulsarProducerFactory<T>- 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:
org.apache.pulsar.client.api.PulsarClientException- if any error occurs
-
doCreateProducer
protected org.apache.pulsar.client.api.Producer<T> doCreateProducer(org.apache.pulsar.client.api.Schema<T> schema, @Nullable String topic, @Nullable Collection<String> encryptionKeys, @Nullable List<ProducerBuilderCustomizer<T>> customizers) throws org.apache.pulsar.client.api.PulsarClientException Create the actual 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 created producer
- Throws:
org.apache.pulsar.client.api.PulsarClientException- if any error occurs
-
resolveTopicName
-
getProducerConfig
Description copied from interface:PulsarProducerFactoryReturn a map of configuration options to use when creating producers.- Specified by:
getProducerConfigin interfacePulsarProducerFactory<T>- Returns:
- the map of configuration options
-