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, Jonas Geiregat
  • 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 sent
      topic - the topic the producer will send messages to or null to 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 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:
      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 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:
      PulsarException - 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