Package org.apache.pulsar.client.api
Interface PulsarClient
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Implementing Classes:
PulsarClientV1Impl
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the PulsarClient and release all the resources.Asynchronously close the PulsarClient and release all the resources.static PulsarClientDeprecated.static PulsarClientcreate(String serviceUrl, ClientConfiguration conf) Deprecated.use#builder()to construct a client instancecreateProducer(String topic) Deprecated.use#newProducer()to build a new producercreateProducer(String topic, ProducerConfiguration conf) Deprecated.use#newProducer()to build a new producercreateProducerAsync(String topic) Deprecated.use#newProducer()to build a new producercreateProducerAsync(String topic, ProducerConfiguration conf) Deprecated.use#newProducer()to build a new producercreateReader(String topic, org.apache.pulsar.client.api.MessageId startMessageId, ReaderConfiguration conf) Deprecated.Use#newReader()to build a new readercreateReaderAsync(String topic, org.apache.pulsar.client.api.MessageId startMessageId, ReaderConfiguration conf) Deprecated.Use#newReader()to build a new readervoidshutdown()Perform immediate shutdown of PulsarClient.Deprecated.Use#newConsumer()to build a new consumersubscribe(String topic, String subscription, ConsumerConfiguration conf) Deprecated.Use#newConsumer()to build a new consumersubscribeAsync(String topic, String subscription) Deprecated.Use#newConsumer()to build a new consumersubscribeAsync(String topic, String subscription, ConsumerConfiguration conf) Deprecated.Use#newConsumer()to build a new consumer
-
Method Details
-
create
@Deprecated static PulsarClient create(String serviceUrl) throws org.apache.pulsar.client.api.PulsarClientException Deprecated.use#builder()to construct a client instanceCreate a new PulsarClient object using default client configuration.- Parameters:
serviceUrl- the url of the Pulsar endpoint to be used- Returns:
- a new pulsar client object
- Throws:
org.apache.pulsar.client.api.PulsarClientException.InvalidServiceURL- if the serviceUrl is invalidorg.apache.pulsar.client.api.PulsarClientException
-
create
@Deprecated static PulsarClient create(String serviceUrl, ClientConfiguration conf) throws org.apache.pulsar.client.api.PulsarClientException Deprecated.use#builder()to construct a client instanceCreate a new PulsarClient object.- Parameters:
serviceUrl- the url of the Pulsar endpoint to be usedconf- the client configuration- Returns:
- a new pulsar client object
- Throws:
org.apache.pulsar.client.api.PulsarClientException.InvalidServiceURL- if the serviceUrl is invalidorg.apache.pulsar.client.api.PulsarClientException
-
createProducer
@Deprecated Producer createProducer(String topic) throws org.apache.pulsar.client.api.PulsarClientException Deprecated.use#newProducer()to build a new producerCreate a producer with defaultProducerConfigurationfor publishing on a specific topic.- 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
Deprecated.use#newProducer()to build a new producerAsynchronously create a producer with defaultProducerConfigurationfor publishing on a specific topic.- Parameters:
topic- The name of the topic where to produce- Returns:
- Future of the asynchronously created producer object
-
createProducer
@Deprecated Producer createProducer(String topic, ProducerConfiguration conf) throws org.apache.pulsar.client.api.PulsarClientException Deprecated.use#newProducer()to build a new producerCreate a producer with givenProducerConfigurationfor publishing on a specific topic.- 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 producerInterruptedException
-
createProducerAsync
@Deprecated CompletableFuture<Producer> createProducerAsync(String topic, ProducerConfiguration conf) Deprecated.use#newProducer()to build a new producerAsynchronously create a producer with givenProducerConfigurationfor publishing on a specific topic.- Parameters:
topic- The name of the topic where to produceconf- TheProducerConfigurationobject- Returns:
- Future of the asynchronously created producer object
-
subscribe
@Deprecated Consumer subscribe(String topic, String subscription) throws org.apache.pulsar.client.api.PulsarClientException Deprecated.Use#newConsumer()to build a new consumerSubscribe to the given topic and subscription combination with defaultConsumerConfiguration.- Parameters:
topic- The name of the topicsubscription- The name of the subscription- Returns:
- The
Consumerobject - Throws:
org.apache.pulsar.client.api.PulsarClientExceptionInterruptedException
-
subscribeAsync
Deprecated.Use#newConsumer()to build a new consumerAsynchronously subscribe to the given topic and subscription combination using default.ConsumerConfiguration- Parameters:
topic- The topic namesubscription- The subscription name- Returns:
- Future of the
Consumerobject
-
subscribe
@Deprecated Consumer subscribe(String topic, String subscription, ConsumerConfiguration conf) throws org.apache.pulsar.client.api.PulsarClientException Deprecated.Use#newConsumer()to build a new consumerSubscribe to the given topic and subscription combination with givenConsumerConfiguration.- Parameters:
topic- The name of the topicsubscription- The name of the subscriptionconf- TheConsumerConfigurationobject- Returns:
- The
Consumerobject - Throws:
org.apache.pulsar.client.api.PulsarClientException
-
subscribeAsync
@Deprecated CompletableFuture<Consumer> subscribeAsync(String topic, String subscription, ConsumerConfiguration conf) Deprecated.Use#newConsumer()to build a new consumerAsynchronously subscribe to the given topic and subscription combination using given.ConsumerConfiguration- Parameters:
topic- The name of the topicsubscription- The name of the subscriptionconf- TheConsumerConfigurationobject- Returns:
- Future of the
Consumerobject
-
createReader
@Deprecated Reader createReader(String topic, org.apache.pulsar.client.api.MessageId startMessageId, ReaderConfiguration conf) throws org.apache.pulsar.client.api.PulsarClientException Deprecated.Use#newReader()to build a new readerCreate 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.
- 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
@Deprecated CompletableFuture<Reader> createReaderAsync(String topic, org.apache.pulsar.client.api.MessageId startMessageId, ReaderConfiguration conf) Deprecated.Use#newReader()to build a new readerAsynchronously 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.
- 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
-
close
void close() throws org.apache.pulsar.client.api.PulsarClientExceptionClose 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- Throws:
org.apache.pulsar.client.api.PulsarClientException- if the close operation fails
-
closeAsync
CompletableFuture<Void> closeAsync()Asynchronously 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.- Throws:
org.apache.pulsar.client.api.PulsarClientException- if the close operation fails
-
shutdown
void shutdown() throws org.apache.pulsar.client.api.PulsarClientExceptionPerform immediate shutdown of PulsarClient. Release all the resources and close all the producers without waiting for ongoing operations to complete.- Throws:
org.apache.pulsar.client.api.PulsarClientException- if the forceful shutdown fails
-
#builder()to construct a client instance