public class ReaderBuilderImpl<T> extends Object implements ReaderBuilder<T>
| Modifier and Type | Method and Description |
|---|---|
ReaderBuilder<T> |
clone()
Create a copy of the current
ReaderBuilder. |
Reader<T> |
create()
Finalize the creation of the
Reader instance. |
CompletableFuture<Reader<T>> |
createAsync()
Finalize the creation of the
Reader instance in asynchronous mode. |
ReaderBuilder<T> |
cryptoFailureAction(ConsumerCryptoFailureAction action)
Sets the ConsumerCryptoFailureAction to the value specified
|
ReaderBuilder<T> |
cryptoKeyReader(CryptoKeyReader cryptoKeyReader)
Sets a
CryptoKeyReader |
ReaderBuilder<T> |
loadConf(Map<String,Object> config)
Load the configuration from provided config map.
|
ReaderBuilder<T> |
readCompacted(boolean readCompacted)
If enabled, the reader will read messages from the compacted topic rather than reading the full message backlog
of the topic.
|
ReaderBuilder<T> |
readerListener(ReaderListener<T> readerListener)
Sets a
ReaderListener for the reader |
ReaderBuilder<T> |
readerName(String readerName)
Set the reader name.
|
ReaderBuilder<T> |
receiverQueueSize(int receiverQueueSize)
Sets the size of the consumer receive queue.
|
ReaderBuilder<T> |
startMessageId(MessageId startMessageId)
The initial reader positioning is done by specifying a message id.
|
ReaderBuilder<T> |
subscriptionRolePrefix(String subscriptionRolePrefix)
Set the subscription role prefix.
|
ReaderBuilder<T> |
topic(String topicName)
Specify the topic this consumer will subscribe on.
|
public ReaderBuilder<T> clone()
ReaderBuilderReaderBuilder.
Cloning the builder can be used to share an incomplete configuration and specialize it multiple times. For example:
ReaderBuilder builder = client.newReader().readerName("my-reader").receiverQueueSize(10);
Reader reader1 = builder.clone().topic(TOPIC_1).create();
Reader reader2 = builder.clone().topic(TOPIC_2).create();
clone in interface ReaderBuilder<T>clone in class Objectpublic Reader<T> create() throws PulsarClientException
ReaderBuilderReader instance.
This method will block until the reader is created successfully.
create in interface ReaderBuilder<T>PulsarClientException - if the reader creation failspublic CompletableFuture<Reader<T>> createAsync()
ReaderBuilderReader instance in asynchronous mode.
This method will return a CompletableFuture that can be used to access the instance when it's ready.
createAsync in interface ReaderBuilder<T>public ReaderBuilder<T> loadConf(Map<String,Object> config)
ReaderBuilderExample:
Map<String, Object> config = new HashMap<>();
config.put("topicName", "test-topic");
config.put("receiverQueueSize", 2000);
ReaderBuilder<byte[]> builder = ...;
builder = builder.loadConf(config);
Reader<byte[]> reader = builder.create();
loadConf in interface ReaderBuilder<T>config - configuration to loadpublic ReaderBuilder<T> topic(String topicName)
ReaderBuilderThis argument is required when constructing the consumer.
topic in interface ReaderBuilder<T>public ReaderBuilder<T> startMessageId(MessageId startMessageId)
ReaderBuilderMessageId.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.
startMessageId in interface ReaderBuilder<T>public ReaderBuilder<T> readerListener(ReaderListener<T> readerListener)
ReaderBuilderReaderListener for the reader
When a ReaderListener is set, application will receive messages through it. Calls to
Reader.readNext() will not be allowed.
readerListener in interface ReaderBuilder<T>readerListener - the listener objectpublic ReaderBuilder<T> cryptoKeyReader(CryptoKeyReader cryptoKeyReader)
ReaderBuilderCryptoKeyReadercryptoKeyReader in interface ReaderBuilder<T>cryptoKeyReader - CryptoKeyReader objectpublic ReaderBuilder<T> cryptoFailureAction(ConsumerCryptoFailureAction action)
ReaderBuildercryptoFailureAction in interface ReaderBuilder<T>action - The action to take when the decoding failspublic ReaderBuilder<T> receiverQueueSize(int receiverQueueSize)
ReaderBuilder
The consumer receive queue controls how many messages can be accumulated by the Consumer before the
application calls Consumer.receive(). Using a higher value could potentially increase the consumer
throughput at the expense of bigger memory utilization.
1000 messages and should be good for most use cases.receiverQueueSize in interface ReaderBuilder<T>receiverQueueSize - the new receiver queue size valuepublic ReaderBuilder<T> readerName(String readerName)
ReaderBuilderreaderName in interface ReaderBuilder<T>public ReaderBuilder<T> subscriptionRolePrefix(String subscriptionRolePrefix)
ReaderBuildersubscriptionRolePrefix in interface ReaderBuilder<T>public ReaderBuilder<T> readCompacted(boolean readCompacted)
ReaderBuilderreadCompacted in interface ReaderBuilder<T>readCompacted - whether to read from the compacted topicCopyright © 2017–2018 Apache Software Foundation. All rights reserved.