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).
Author:
Soby Chacko, Chris Bono, Alexander Preuß, Christophe Bornet
  • Method Details

    • createProducer

      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
      Create a producer.
      Parameters:
      schema - the schema of the messages to be sent
      topic - the topic the producer will send messages to or null to use the default topic
      Returns:
      the producer
      Throws:
      org.apache.pulsar.client.api.PulsarClientException - 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) throws org.apache.pulsar.client.api.PulsarClientException
      Create a producer.
      Parameters:
      schema - the schema of the messages to be sent
      topic - the topic the producer will send messages to or null to use the default topic
      customizer - the optional customizer to apply to the producer builder
      Returns:
      the producer
      Throws:
      org.apache.pulsar.client.api.PulsarClientException - 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) throws org.apache.pulsar.client.api.PulsarClientException
      Create a producer.
      Parameters:
      schema - the schema of the messages to be sent
      topic - the topic the producer will send messages to or null to use the default topic
      encryptionKeys - the encryption keys used by the producer, replacing the default encryption keys or null to use the default encryption keys. Beware that ProducerBuilder only has ProducerBuilder.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
    • getDefaultTopic

      @Nullable String 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