Interface ReactiveMessageReaderBuilder<T>

  • Type Parameters:
    T - the message payload type

    public interface ReactiveMessageReaderBuilder<T>
    Builder interface for ReactiveMessageReader.
    • Method Detail

      • startAtSpec

        ReactiveMessageReaderBuilder<T> startAtSpec​(StartAtSpec startAtSpec)
        Sets the position where to start reading from.

        This setting applies to each new Reader created under the built ReactiveMessageReader.

        Parameters:
        startAtSpec - the position where to start reading from
        Returns:
        the reader builder instance
        See Also:
        ReaderBuilder.startMessageId(MessageId), ReaderBuilder.startMessageIdInclusive(), ReaderBuilder.startMessageFromRollbackDuration(long, TimeUnit)
      • endOfStreamAction

        ReactiveMessageReaderBuilder<T> endOfStreamAction​(EndOfStreamAction endOfStreamAction)
        Sets the action to perform once the end of the stream is reached.
        Parameters:
        endOfStreamAction - the action to perform once the end of the stream is reached
        Returns:
        the reader builder instance
      • toImmutableSpec

        default ReactiveMessageReaderSpec toImmutableSpec()
        Gets an immutable spec from the underlying spec of this builder.
        Returns:
        the immutable reactive reader spec.
      • clone

        ReactiveMessageReaderBuilder<T> clone()
        Creates and returns a copy of this reactive reader builder.
        Returns:
        the cloned reactive reader builder
      • topic

        default ReactiveMessageReaderBuilder<T> topic​(java.lang.String topicName)
        Adds a topic this reader will read from.
        Parameters:
        topicName - the name of the topic to add
        Returns:
        the reader builder instance
        See Also:
        ReaderBuilder.topic(String)
      • topic

        default ReactiveMessageReaderBuilder<T> topic​(java.lang.String... topicNames)
        Adds topics this reader will read from.
        Parameters:
        topicNames - the names of the topics to add
        Returns:
        the reader builder instance
        See Also:
        ReaderBuilder.topic(String)
      • topics

        default ReactiveMessageReaderBuilder<T> topics​(java.util.List<java.lang.String> topicNames)
        Sets the topics this reader will read from.
        Parameters:
        topicNames - the names of the topics to set
        Returns:
        the reader builder instance
        See Also:
        ReaderBuilder.topics(List)
      • readerName

        default ReactiveMessageReaderBuilder<T> readerName​(java.lang.String readerName)
        Sets the reader name.

        The reader name is purely informational and can be used to track a particular reader in the reported stats. By default, a randomly generated name is used for each Reader created under the built ReactiveMessageReader.

        Parameters:
        readerName - the name to use for the reader
        Returns:
        the reader builder instance
        See Also:
        ReaderBuilder.readerName(String)
      • subscriptionName

        default ReactiveMessageReaderBuilder<T> subscriptionName​(java.lang.String subscriptionName)
        Sets the subscription name.

        If generatedSubscriptionNamePrefix(java.lang.String) is set at the same time, this configuration will prevail.

        Parameters:
        subscriptionName - the name of the subscription to set
        Returns:
        the reader builder instance
        See Also:
        ReaderBuilder.subscriptionName(String)
      • generatedSubscriptionNamePrefix

        default ReactiveMessageReaderBuilder<T> generatedSubscriptionNamePrefix​(java.lang.String generatedSubscriptionNamePrefix)
        Sets the generated subscription name prefix. The default prefix is "reader". A subscription name will be generated for each Reader created under the built ReactiveMessageReader.
        Parameters:
        generatedSubscriptionNamePrefix - the generated subscription name prefix to set
        Returns:
        the reader builder instance
        See Also:
        ReaderBuilder.subscriptionRolePrefix(String)
      • receiverQueueSize

        default ReactiveMessageReaderBuilder<T> receiverQueueSize​(java.lang.Integer receiverQueueSize)
        Sets the size of the reader receiver queue.

        The setting applies to each Reader created under the built ReactiveMessageReader.

        The reader receiver queue controls how many messages will be prefetched into the Reader. Using a higher value could potentially increase the reader throughput at the expense of bigger memory utilization.

        The default value is 1000 messages and should be good for most use cases.

        Parameters:
        receiverQueueSize - the receiver queue size to set
        Returns:
        the reader builder instance
        See Also:
        ReaderBuilder.receiverQueueSize(int)
      • readCompacted

        default ReactiveMessageReaderBuilder<T> readCompacted​(java.lang.Boolean readCompacted)
        Sets whether the reader will read messages from the compacted topic rather than reading the full message backlog of the topic. This means that, if the topic has been compacted, the reader will only see the latest value for each key in the topic, up until the point in the topic message backlog that has been compacted. Beyond that point, the messages will be sent as normal.

        readCompacted can only be enabled for subscriptions to persistent topics, which have a single active consumer (i.e. failover or exclusive subscriptions). Attempting to enable it on subscriptions to a non-persistent topic or on a shared subscription, will lead to the ReactiveMessageReader.readOne()/ReactiveMessageReader.readMany() calls emitting an PulsarClientException.

        Parameters:
        readCompacted - whether to read from the compacted topic
        Returns:
        the reader builder instance
        See Also:
        ReaderBuilder.readCompacted(boolean)
      • keyHashRanges

        default ReactiveMessageReaderBuilder<T> keyHashRanges​(java.util.List<org.apache.pulsar.client.api.Range> keyHashRanges)
        Sets the key hash ranges of the reader. The broker will only dispatch messages for which the hash of the message key is inside the one of the key hash ranges. Multiple key hash ranges can be specified on a reader.

        Total hash range size is 65536, so the maximum end of the range should be less than or equal to 65535.

        Parameters:
        keyHashRanges - the key hash ranges to set
        Returns:
        the reader builder instance
        See Also:
        ReaderBuilder.keyHashRange(Range...)
      • cryptoKeyReader

        default ReactiveMessageReaderBuilder<T> cryptoKeyReader​(org.apache.pulsar.client.api.CryptoKeyReader cryptoKeyReader)
        Sets the key reader to be used to decrypt the message payloads.
        Parameters:
        cryptoKeyReader - the key reader to be used to decrypt the message payloads.
        Returns:
        the consumer builder instance
        See Also:
        ReaderBuilder.cryptoKeyReader(CryptoKeyReader)
      • cryptoFailureAction

        default ReactiveMessageReaderBuilder<T> cryptoFailureAction​(org.apache.pulsar.client.api.ConsumerCryptoFailureAction cryptoFailureAction)
        Sets the action the reader will take in case of decryption failures.
        Parameters:
        cryptoFailureAction - the action the consumer will take in case of decryption failures
        Returns:
        the reader builder instance
        See Also:
        ReaderBuilder.cryptoFailureAction(ConsumerCryptoFailureAction)