Package org.springframework.pulsar.core
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>
Default implementation for
PulsarConsumerFactory.- Author:
- Soby Chacko, Alexander Preuß, Christophe Bornet
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultPulsarConsumerFactory(org.apache.pulsar.client.api.PulsarClient pulsarClient) DefaultPulsarConsumerFactory(org.apache.pulsar.client.api.PulsarClient pulsarClient, Map<String, Object> consumerConfig) -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.pulsar.client.api.Consumer<T>createConsumer(org.apache.pulsar.client.api.Schema<T> schema) Create a consumer.org.apache.pulsar.client.api.Consumer<T>createConsumer(org.apache.pulsar.client.api.Schema<T> schema, Collection<String> topics) Create a consumer.org.apache.pulsar.client.api.Consumer<T>createConsumer(org.apache.pulsar.client.api.Schema<T> schema, Collection<String> topics, Map<String, String> properties, List<ConsumerBuilderCustomizer<T>> customizers) Create a consumer.Return the configuration options to use when creating consumers.
-
Constructor Details
-
DefaultPulsarConsumerFactory
public DefaultPulsarConsumerFactory(org.apache.pulsar.client.api.PulsarClient pulsarClient) -
DefaultPulsarConsumerFactory
-
-
Method Details
-
createConsumer
public org.apache.pulsar.client.api.Consumer<T> createConsumer(org.apache.pulsar.client.api.Schema<T> schema) throws org.apache.pulsar.client.api.PulsarClientException Description copied from interface:PulsarConsumerFactoryCreate a consumer.- Specified by:
createConsumerin interfacePulsarConsumerFactory<T>- Parameters:
schema- the schema of the messages to be sent- Returns:
- the consumer
- Throws:
org.apache.pulsar.client.api.PulsarClientException- if any error occurs
-
createConsumer
public org.apache.pulsar.client.api.Consumer<T> createConsumer(org.apache.pulsar.client.api.Schema<T> schema, @Nullable Collection<String> topics) throws org.apache.pulsar.client.api.PulsarClientException Description copied from interface:PulsarConsumerFactoryCreate a consumer.- Specified by:
createConsumerin interfacePulsarConsumerFactory<T>- Parameters:
schema- the schema of the messages to be senttopics- the topics the consumer will subscribe to overriding the default ones ornullto use the default topics- Returns:
- the consumer
- Throws:
org.apache.pulsar.client.api.PulsarClientException- if any error occurs
-
createConsumer
public org.apache.pulsar.client.api.Consumer<T> createConsumer(org.apache.pulsar.client.api.Schema<T> schema, @Nullable Collection<String> topics, @Nullable Map<String, String> properties, @Nullable List<ConsumerBuilderCustomizer<T>> customizers) throws org.apache.pulsar.client.api.PulsarClientExceptionDescription copied from interface:PulsarConsumerFactoryCreate a consumer.- Specified by:
createConsumerin interfacePulsarConsumerFactory<T>- Parameters:
schema- the schema of the messages to be senttopics- the topics the consumer will subscribe to overriding the default ones ornullto use the default topics. Beware that usingConsumerBuilder.topic(java.lang.String...)orConsumerBuilder.topics(java.util.List<java.lang.String>)will add to the default topics, not override them.properties- the metadata properties to attach to the consumer, replacing the default metadata properties, ornullto use the default metadata properties. Beware that usingConsumerBuilder.property(java.lang.String, java.lang.String)orConsumerBuilder.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- Returns:
- the consumer
- Throws:
org.apache.pulsar.client.api.PulsarClientException- if any error occurs
-
getConsumerConfig
Description copied from interface:PulsarConsumerFactoryReturn the configuration options to use when creating consumers.- Specified by:
getConsumerConfigin interfacePulsarConsumerFactory<T>- Returns:
- the configuration options
-