Package org.apache.pulsar.client.impl.v1
Class PulsarClientV1Impl
java.lang.Object
org.apache.pulsar.client.impl.v1.PulsarClientV1Impl
- All Implemented Interfaces:
Closeable,AutoCloseable,PulsarClient
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the PulsarClient and release all the resources.Asynchronously close the PulsarClient and release all the resources.createProducer(String topic) Create a producer with defaultProducerConfigurationfor publishing on a specific topic.createProducer(String topic, ProducerConfiguration conf) Create a producer with givenProducerConfigurationfor publishing on a specific topic.createProducerAsync(String topic) Asynchronously create a producer with defaultProducerConfigurationfor publishing on a specific topic.createProducerAsync(String topic, ProducerConfiguration conf) Asynchronously create a producer with givenProducerConfigurationfor publishing on a specific topic.createReader(String topic, org.apache.pulsar.client.api.MessageId startMessageId, ReaderConfiguration conf) Create a topic reader with givenReaderConfigurationfor reading messages from the specified topic.createReaderAsync(String topic, org.apache.pulsar.client.api.MessageId startMessageId, ReaderConfiguration conf) Asynchronously create a topic reader with givenReaderConfigurationfor reading messages from the specified topic.voidshutdown()Perform immediate shutdown of PulsarClient.Subscribe to the given topic and subscription combination with defaultConsumerConfiguration.subscribe(String topic, String subscription, ConsumerConfiguration conf) Subscribe to the given topic and subscription combination with givenConsumerConfiguration.subscribeAsync(String topic, String subscriptionName) Asynchronously subscribe to the given topic and subscription combination using default.subscribeAsync(String topic, String subscription, ConsumerConfiguration conf) Asynchronously subscribe to the given topic and subscription combination using given.
-
Constructor Details
-
PulsarClientV1Impl
public PulsarClientV1Impl(String serviceUrl, ClientConfiguration conf) throws org.apache.pulsar.client.api.PulsarClientException - Throws:
org.apache.pulsar.client.api.PulsarClientException
-
-
Method Details
-
close
public void close() throws org.apache.pulsar.client.api.PulsarClientExceptionDescription copied from interface:PulsarClientClose the PulsarClient and release all the resources. All the producers and consumers will be orderly closed. Waits until all pending write request are persisted.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfacePulsarClient- Throws:
org.apache.pulsar.client.api.PulsarClientException- if the close operation fails
-
closeAsync
Description copied from interface:PulsarClientAsynchronously close the PulsarClient and release all the resources. All the producers and consumers will be orderly closed. Waits until all pending write request are persisted.- Specified by:
closeAsyncin interfacePulsarClient
-
createProducer
public Producer createProducer(String topic, ProducerConfiguration conf) throws org.apache.pulsar.client.api.PulsarClientException Description copied from interface:PulsarClientCreate a producer with givenProducerConfigurationfor publishing on a specific topic.- Specified by:
createProducerin interfacePulsarClient- Parameters:
topic- The name of the topic where to produceconf- TheProducerConfigurationobject- Returns:
- The producer object
- Throws:
org.apache.pulsar.client.api.PulsarClientException- if it was not possible to create the producer
-
createProducer
public Producer createProducer(String topic) throws org.apache.pulsar.client.api.PulsarClientException Description copied from interface:PulsarClientCreate a producer with defaultProducerConfigurationfor publishing on a specific topic.- Specified by:
createProducerin interfacePulsarClient- Parameters:
topic- The name of the topic where to produce- Returns:
- The producer object
- Throws:
org.apache.pulsar.client.api.PulsarClientException.AlreadyClosedException- if the client was already closedorg.apache.pulsar.client.api.PulsarClientException.InvalidTopicNameException- if the topic name is not validorg.apache.pulsar.client.api.PulsarClientException.AuthenticationException- if there was an error with the supplied credentialsorg.apache.pulsar.client.api.PulsarClientException.AuthorizationException- if the authorization to publish on topic was deniedorg.apache.pulsar.client.api.PulsarClientException
-
createProducerAsync
Description copied from interface:PulsarClientAsynchronously create a producer with givenProducerConfigurationfor publishing on a specific topic.- Specified by:
createProducerAsyncin interfacePulsarClient- Parameters:
topic- The name of the topic where to produceconf- TheProducerConfigurationobject- Returns:
- Future of the asynchronously created producer object
-
createProducerAsync
Description copied from interface:PulsarClientAsynchronously create a producer with defaultProducerConfigurationfor publishing on a specific topic.- Specified by:
createProducerAsyncin interfacePulsarClient- Parameters:
topic- The name of the topic where to produce- Returns:
- Future of the asynchronously created producer object
-
createReader
public Reader createReader(String topic, org.apache.pulsar.client.api.MessageId startMessageId, ReaderConfiguration conf) throws org.apache.pulsar.client.api.PulsarClientException Description copied from interface:PulsarClientCreate a topic reader with givenReaderConfigurationfor reading messages from the specified topic.The Reader provides a low-level abstraction that allows for manual positioning in the topic, without using a subscription. Reader can only work on non-partitioned topics.
The initial reader positioning is done by specifying a message id. The options are:
MessageId.earliest: Start reading from the earliest message available in the topicMessageId.latest: Start reading from the end topic, only getting messages published after the reader was createdMessageId: When passing a particular message id, the reader will position itself on that specific position. The first message to be read will be the message next to the specified messageId.
- Specified by:
createReaderin interfacePulsarClient- Parameters:
topic- The name of the topic where to readstartMessageId- The message id where the reader will position itself. The first message returned will be the one after the specified startMessageIdconf- TheReaderConfigurationobject- Returns:
- The
Readerobject - Throws:
org.apache.pulsar.client.api.PulsarClientException
-
createReaderAsync
public CompletableFuture<Reader> createReaderAsync(String topic, org.apache.pulsar.client.api.MessageId startMessageId, ReaderConfiguration conf) Description copied from interface:PulsarClientAsynchronously create a topic reader with givenReaderConfigurationfor reading messages from the specified topic.The Reader provides a low-level abstraction that allows for manual positioning in the topic, without using a subscription. Reader can only work on non-partitioned topics.
The initial reader positioning is done by specifying a message id. The options are:
MessageId.earliest: Start reading from the earliest message available in the topicMessageId.latest: Start reading from the end topic, only getting messages published after the reader was createdMessageId: When passing a particular message id, the reader will position itself on that specific position. The first message to be read will be the message next to the specified messageId.
- Specified by:
createReaderAsyncin interfacePulsarClient- Parameters:
topic- The name of the topic where to readstartMessageId- The message id where the reader will position itself. The first message returned will be the one after the specified startMessageIdconf- TheReaderConfigurationobject- Returns:
- Future of the asynchronously created producer object
-
shutdown
public void shutdown() throws org.apache.pulsar.client.api.PulsarClientExceptionDescription copied from interface:PulsarClientPerform immediate shutdown of PulsarClient. Release all the resources and close all the producers without waiting for ongoing operations to complete.- Specified by:
shutdownin interfacePulsarClient- Throws:
org.apache.pulsar.client.api.PulsarClientException- if the forceful shutdown fails
-
subscribe
public Consumer subscribe(String topic, String subscriptionName) throws org.apache.pulsar.client.api.PulsarClientException Description copied from interface:PulsarClientSubscribe to the given topic and subscription combination with defaultConsumerConfiguration.- Specified by:
subscribein interfacePulsarClient- Parameters:
topic- The name of the topicsubscriptionName- The name of the subscription- Returns:
- The
Consumerobject - Throws:
org.apache.pulsar.client.api.PulsarClientException
-
subscribeAsync
public CompletableFuture<Consumer> subscribeAsync(String topic, String subscription, ConsumerConfiguration conf) Description copied from interface:PulsarClientAsynchronously subscribe to the given topic and subscription combination using given.ConsumerConfiguration- Specified by:
subscribeAsyncin interfacePulsarClient- Parameters:
topic- The name of the topicsubscription- The name of the subscriptionconf- TheConsumerConfigurationobject- Returns:
- Future of the
Consumerobject
-
subscribeAsync
Description copied from interface:PulsarClientAsynchronously subscribe to the given topic and subscription combination using default.ConsumerConfiguration- Specified by:
subscribeAsyncin interfacePulsarClient- Parameters:
topic- The topic namesubscriptionName- The subscription name- Returns:
- Future of the
Consumerobject
-
subscribe
public Consumer subscribe(String topic, String subscription, ConsumerConfiguration conf) throws org.apache.pulsar.client.api.PulsarClientException Description copied from interface:PulsarClientSubscribe to the given topic and subscription combination with givenConsumerConfiguration.- Specified by:
subscribein interfacePulsarClient- Parameters:
topic- The name of the topicsubscription- The name of the subscriptionconf- TheConsumerConfigurationobject- Returns:
- The
Consumerobject - Throws:
org.apache.pulsar.client.api.PulsarClientException
-