Class DefaultPulsarConsumerFactory<T>

java.lang.Object
org.springframework.pulsar.core.DefaultPulsarConsumerFactory<T>
Type Parameters:
T - underlying payload type for the consumer.
All Implemented Interfaces:
PulsarConsumerFactory<T>

public class DefaultPulsarConsumerFactory<T> extends Object implements PulsarConsumerFactory<T>
Default implementation for PulsarConsumerFactory.
Author:
Soby Chacko, Alexander Preuß, Christophe Bornet, Chris Bono, Jonas Geiregat
  • Constructor Details

    • DefaultPulsarConsumerFactory

      public DefaultPulsarConsumerFactory(org.apache.pulsar.client.api.PulsarClient pulsarClient, List<ConsumerBuilderCustomizer<T>> defaultConfigCustomizers)
      Construct a consumer factory instance.
      Parameters:
      pulsarClient - the client used to consume
      defaultConfigCustomizers - the optional list of customizers to apply to the created consumers or null to use no default configuration
  • Method Details

    • createConsumer

      public org.apache.pulsar.client.api.Consumer<T> createConsumer(org.apache.pulsar.client.api.Schema<T> schema, @Nullable Collection<String> topics, @Nullable String subscriptionName, ConsumerBuilderCustomizer<T> customizer)
      Description copied from interface: PulsarConsumerFactory
      Create a consumer.
      Specified by:
      createConsumer in interface PulsarConsumerFactory<T>
      Parameters:
      schema - the schema of the messages to be sent
      topics - the topics the consumer will subscribe to, replacing the default topics, or null to use the default topics. Beware that using ConsumerBuilder.topic(java.lang.String...) or ConsumerBuilder.topics(java.util.List<java.lang.String>) will add to the default topics, not override them. Also beware that specifying null when no default topic is configured will result in an exception.
      subscriptionName - the name to use for the subscription to the consumed topic(s) or null to use the default configured subscription name. Beware that specifying null when no default subscription name is configured will result in an exception
      customizer - an optional customizer to apply to the consumer builder. Note that the customizer is applied last and has the potential for overriding any specified parameters or default properties.
      Returns:
      the consumer
    • createConsumer

      public org.apache.pulsar.client.api.Consumer<T> createConsumer(org.apache.pulsar.client.api.Schema<T> schema, @Nullable Collection<String> topics, @Nullable String subscriptionName, @Nullable Map<String,String> metadataProperties, @Nullable List<ConsumerBuilderCustomizer<T>> customizers)
      Description copied from interface: PulsarConsumerFactory
      Create a consumer.
      Specified by:
      createConsumer in interface PulsarConsumerFactory<T>
      Parameters:
      schema - the schema of the messages to be sent
      topics - the topics the consumer will subscribe to, replacing the default topics, or null to use the default topics. Beware that using ConsumerBuilder.topic(java.lang.String...) or ConsumerBuilder.topics(java.util.List<java.lang.String>) will add to the default topics, not override them. Also beware that specifying null when no default topic is configured will result in an exception.
      subscriptionName - the name to use for the subscription to the consumed topic(s) or null to use the default configured subscription name. Beware that specifying null when no default subscription name is configured will result in an exception
      metadataProperties - the metadata properties to attach to the consumer, replacing the default metadata properties, or null to use the default metadata properties. Beware that using ConsumerBuilder.property(java.lang.String, java.lang.String) or ConsumerBuilder.properties(java.util.Map<java.lang.String, java.lang.String>) will add to the default metadata properties, not replace them.
      customizers - the optional list of customizers to apply to the consumer builder. Note that the customizers are applied last and have the potential for overriding any specified parameters or default properties.
      Returns:
      the consumer