Class PulsarClientV1Impl

java.lang.Object
org.apache.pulsar.client.impl.v1.PulsarClientV1Impl
All Implemented Interfaces:
Closeable, AutoCloseable, PulsarClient

public class PulsarClientV1Impl extends Object implements PulsarClient
  • 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.PulsarClientException
      Description copied from interface: PulsarClient
      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:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface PulsarClient
      Throws:
      org.apache.pulsar.client.api.PulsarClientException - if the close operation fails
    • closeAsync

      public CompletableFuture<Void> closeAsync()
      Description copied from interface: PulsarClient
      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.
      Specified by:
      closeAsync in interface PulsarClient
    • createProducer

      public Producer createProducer(String topic, ProducerConfiguration conf) throws org.apache.pulsar.client.api.PulsarClientException
      Description copied from interface: PulsarClient
      Create a producer with given ProducerConfiguration for publishing on a specific topic.
      Specified by:
      createProducer in interface PulsarClient
      Parameters:
      topic - The name of the topic where to produce
      conf - The ProducerConfiguration object
      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: PulsarClient
      Create a producer with default ProducerConfiguration for publishing on a specific topic.
      Specified by:
      createProducer in interface PulsarClient
      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 closed
      org.apache.pulsar.client.api.PulsarClientException.InvalidTopicNameException - if the topic name is not valid
      org.apache.pulsar.client.api.PulsarClientException.AuthenticationException - if there was an error with the supplied credentials
      org.apache.pulsar.client.api.PulsarClientException.AuthorizationException - if the authorization to publish on topic was denied
      org.apache.pulsar.client.api.PulsarClientException
    • createProducerAsync

      public CompletableFuture<Producer> createProducerAsync(String topic, ProducerConfiguration conf)
      Description copied from interface: PulsarClient
      Asynchronously create a producer with given ProducerConfiguration for publishing on a specific topic.
      Specified by:
      createProducerAsync in interface PulsarClient
      Parameters:
      topic - The name of the topic where to produce
      conf - The ProducerConfiguration object
      Returns:
      Future of the asynchronously created producer object
    • createProducerAsync

      public CompletableFuture<Producer> createProducerAsync(String topic)
      Description copied from interface: PulsarClient
      Asynchronously create a producer with default ProducerConfiguration for publishing on a specific topic.
      Specified by:
      createProducerAsync in interface PulsarClient
      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: PulsarClient
      Create a topic reader with given ReaderConfiguration for 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 topic
      • MessageId.latest : Start reading from the end topic, only getting messages published after the reader was created
      • MessageId : 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:
      createReader in interface PulsarClient
      Parameters:
      topic - The name of the topic where to read
      startMessageId - The message id where the reader will position itself. The first message returned will be the one after the specified startMessageId
      conf - The ReaderConfiguration object
      Returns:
      The Reader object
      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: PulsarClient
      Asynchronously create a topic reader with given ReaderConfiguration for 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 topic
      • MessageId.latest : Start reading from the end topic, only getting messages published after the reader was created
      • MessageId : 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:
      createReaderAsync in interface PulsarClient
      Parameters:
      topic - The name of the topic where to read
      startMessageId - The message id where the reader will position itself. The first message returned will be the one after the specified startMessageId
      conf - The ReaderConfiguration object
      Returns:
      Future of the asynchronously created producer object
    • shutdown

      public void shutdown() throws org.apache.pulsar.client.api.PulsarClientException
      Description copied from interface: PulsarClient
      Perform immediate shutdown of PulsarClient. Release all the resources and close all the producers without waiting for ongoing operations to complete.
      Specified by:
      shutdown in interface PulsarClient
      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: PulsarClient
      Subscribe to the given topic and subscription combination with default ConsumerConfiguration.
      Specified by:
      subscribe in interface PulsarClient
      Parameters:
      topic - The name of the topic
      subscriptionName - The name of the subscription
      Returns:
      The Consumer object
      Throws:
      org.apache.pulsar.client.api.PulsarClientException
    • subscribeAsync

      public CompletableFuture<Consumer> subscribeAsync(String topic, String subscription, ConsumerConfiguration conf)
      Description copied from interface: PulsarClient
      Asynchronously subscribe to the given topic and subscription combination using given. ConsumerConfiguration
      Specified by:
      subscribeAsync in interface PulsarClient
      Parameters:
      topic - The name of the topic
      subscription - The name of the subscription
      conf - The ConsumerConfiguration object
      Returns:
      Future of the Consumer object
    • subscribeAsync

      public CompletableFuture<Consumer> subscribeAsync(String topic, String subscriptionName)
      Description copied from interface: PulsarClient
      Asynchronously subscribe to the given topic and subscription combination using default. ConsumerConfiguration
      Specified by:
      subscribeAsync in interface PulsarClient
      Parameters:
      topic - The topic name
      subscriptionName - The subscription name
      Returns:
      Future of the Consumer object
    • subscribe

      public Consumer subscribe(String topic, String subscription, ConsumerConfiguration conf) throws org.apache.pulsar.client.api.PulsarClientException
      Description copied from interface: PulsarClient
      Subscribe to the given topic and subscription combination with given ConsumerConfiguration.
      Specified by:
      subscribe in interface PulsarClient
      Parameters:
      topic - The name of the topic
      subscription - The name of the subscription
      conf - The ConsumerConfiguration object
      Returns:
      The Consumer object
      Throws:
      org.apache.pulsar.client.api.PulsarClientException