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 Summary

    Modifier and Type
    Method
    Description
    org.apache.pulsar.client.api.Producer<T>
    createProducer(org.apache.pulsar.client.api.Schema<T> schema)
    Create a producer.
    org.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.
    Return a map of configuration options to use when creating producers.
  • Method Details

    • createProducer

      org.apache.pulsar.client.api.Producer<T> createProducer(org.apache.pulsar.client.api.Schema<T> schema) throws org.apache.pulsar.client.api.PulsarClientException
      Create a producer.
      Parameters:
      schema - the schema of the messages to be sent
      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) 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 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
    • getProducerConfig

      Map<String,Object> getProducerConfig()
      Return a map of configuration options to use when creating producers.
      Returns:
      the map of configuration options