Class ReaderV1Impl

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

public class ReaderV1Impl extends Object implements Reader
  • Constructor Details

    • ReaderV1Impl

      public ReaderV1Impl(org.apache.pulsar.shade.client.api.v2.Reader<byte[]> reader)
  • Method Details

    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • closeAsync

      public CompletableFuture<Void> closeAsync()
      Description copied from interface: Reader
      Asynchronously close the reader and stop the broker to push more messages.
      Specified by:
      closeAsync in interface Reader
      Returns:
      a future that can be used to track the completion of the operation
    • getTopic

      public String getTopic()
      Specified by:
      getTopic in interface Reader
      Returns:
      the topic from which this reader is reading from
    • hasMessageAvailable

      public boolean hasMessageAvailable() throws org.apache.pulsar.client.api.PulsarClientException
      Description copied from interface: Reader
      Check if there is any message available to read from the current position.
      Specified by:
      hasMessageAvailable in interface Reader
      Throws:
      org.apache.pulsar.client.api.PulsarClientException
    • hasMessageAvailableAsync

      public CompletableFuture<Boolean> hasMessageAvailableAsync()
      Description copied from interface: Reader
      Asynchronously Check if there is message that has been published successfully to the broker in the topic.
      Specified by:
      hasMessageAvailableAsync in interface Reader
    • hasReachedEndOfTopic

      public boolean hasReachedEndOfTopic()
      Description copied from interface: Reader
      Return true if the topic was terminated and this reader has reached the end of the topic.
      Specified by:
      hasReachedEndOfTopic in interface Reader
    • isConnected

      public boolean isConnected()
      Specified by:
      isConnected in interface Reader
      Returns:
      Whether the reader is connected to the broker
    • readNext

      public org.apache.pulsar.client.api.Message<byte[]> readNext() throws org.apache.pulsar.client.api.PulsarClientException
      Description copied from interface: Reader
      Read the next message in the topic.
      Specified by:
      readNext in interface Reader
      Returns:
      the next message
      Throws:
      org.apache.pulsar.client.api.PulsarClientException
    • readNext

      public org.apache.pulsar.client.api.Message<byte[]> readNext(int arg0, TimeUnit arg1) throws org.apache.pulsar.client.api.PulsarClientException
      Description copied from interface: Reader
      Read the next message in the topic waiting for a maximum of timeout time units. Returns null if no message is received in that time.
      Specified by:
      readNext in interface Reader
      Returns:
      the next message(Could be null if none received in time)
      Throws:
      org.apache.pulsar.client.api.PulsarClientException
    • readNextAsync

      public CompletableFuture<org.apache.pulsar.client.api.Message<byte[]>> readNextAsync()
      Specified by:
      readNextAsync in interface Reader