public abstract class ConsumerBase<T> extends Object implements io.netty.util.TimerTask, Consumer<T>
| Modifier and Type | Class and Description |
|---|---|
protected static class |
ConsumerBase.OpBatchReceive<T> |
| Modifier and Type | Field and Description |
|---|---|
protected BatchReceivePolicy |
batchReceivePolicy |
protected io.netty.util.Timeout |
batchReceiveTimeout |
protected PulsarClientImpl |
client |
protected ConsumerConfigurationData<T> |
conf |
protected ConsumerEventListener |
consumerEventListener |
protected String |
consumerName |
protected static AtomicLongFieldUpdater<ConsumerBase> |
INCOMING_MESSAGES_SIZE_UPDATER |
protected long |
incomingMessagesSize |
protected ConsumerInterceptors<T> |
interceptors |
protected MessageListener<T> |
listener |
protected ExecutorService |
listenerExecutor |
protected int |
maxReceiverQueueSize |
protected ConcurrentLinkedQueue<ConsumerBase.OpBatchReceive<T>> |
pendingBatchReceives |
protected ConcurrentLinkedQueue<CompletableFuture<Message<T>>> |
pendingReceives |
protected Schema<T> |
schema |
protected CompletableFuture<Consumer<T>> |
subscribeFuture |
protected String |
subscription |
protected String |
topic |
| Modifier | Constructor and Description |
|---|---|
protected |
ConsumerBase(PulsarClientImpl client,
String topic,
ConsumerConfigurationData<T> conf,
int receiverQueueSize,
ExecutorService listenerExecutor,
CompletableFuture<Consumer<T>> subscribeFuture,
Schema<T> schema,
ConsumerInterceptors interceptors) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetStats, hasReachedEndOfTopic, isConnected, negativeAcknowledge, pause, redeliverUnacknowledgedMessages, resume, seek, seek, seekAsync, seekAsyncprotected final String subscription
protected final ConsumerConfigurationData<T> conf
protected final String consumerName
protected final CompletableFuture<Consumer<T>> subscribeFuture
protected final MessageListener<T> listener
protected final ConsumerEventListener consumerEventListener
protected final ExecutorService listenerExecutor
protected final ConcurrentLinkedQueue<CompletableFuture<Message<T>>> pendingReceives
protected int maxReceiverQueueSize
protected final ConsumerInterceptors<T> interceptors
protected final BatchReceivePolicy batchReceivePolicy
protected ConcurrentLinkedQueue<ConsumerBase.OpBatchReceive<T>> pendingBatchReceives
protected static final AtomicLongFieldUpdater<ConsumerBase> INCOMING_MESSAGES_SIZE_UPDATER
protected volatile long incomingMessagesSize
protected volatile io.netty.util.Timeout batchReceiveTimeout
protected final PulsarClientImpl client
protected final String topic
protected ConsumerBase(PulsarClientImpl client, String topic, ConsumerConfigurationData<T> conf, int receiverQueueSize, ExecutorService listenerExecutor, CompletableFuture<Consumer<T>> subscribeFuture, Schema<T> schema, ConsumerInterceptors interceptors)
public Message<T> receive() throws PulsarClientException
receive in interface Consumer<T>PulsarClientExceptionpublic CompletableFuture<Message<T>> receiveAsync()
receiveAsync in interface Consumer<T>protected abstract Message<T> internalReceive() throws PulsarClientException
PulsarClientExceptionprotected abstract CompletableFuture<Message<T>> internalReceiveAsync()
public Message<T> receive(int timeout, TimeUnit unit) throws PulsarClientException
receive in interface Consumer<T>PulsarClientExceptionprotected abstract Message<T> internalReceive(int timeout, TimeUnit unit) throws PulsarClientException
PulsarClientExceptionpublic Messages<T> batchReceive() throws PulsarClientException
batchReceive in interface Consumer<T>PulsarClientExceptionpublic CompletableFuture<Messages<T>> batchReceiveAsync()
batchReceiveAsync in interface Consumer<T>protected abstract Messages<T> internalBatchReceive() throws PulsarClientException
PulsarClientExceptionprotected abstract CompletableFuture<Messages<T>> internalBatchReceiveAsync()
public void acknowledge(Message<?> message) throws PulsarClientException
acknowledge in interface Consumer<T>PulsarClientExceptionpublic void acknowledge(MessageId messageId) throws PulsarClientException
acknowledge in interface Consumer<T>PulsarClientExceptionpublic void acknowledge(Messages<?> messages) throws PulsarClientException
acknowledge in interface Consumer<T>PulsarClientExceptionpublic void acknowledgeCumulative(Message<?> message) throws PulsarClientException
acknowledgeCumulative in interface Consumer<T>PulsarClientExceptionpublic void acknowledgeCumulative(MessageId messageId) throws PulsarClientException
acknowledgeCumulative in interface Consumer<T>PulsarClientExceptionpublic CompletableFuture<Void> acknowledgeAsync(Message<?> message)
acknowledgeAsync in interface Consumer<T>public CompletableFuture<Void> acknowledgeAsync(Messages<?> messages)
acknowledgeAsync in interface Consumer<T>public CompletableFuture<Void> acknowledgeCumulativeAsync(Message<?> message)
acknowledgeCumulativeAsync in interface Consumer<T>public CompletableFuture<Void> acknowledgeAsync(MessageId messageId)
acknowledgeAsync in interface Consumer<T>public CompletableFuture<Void> acknowledgeAsync(MessageId messageId, Transaction txn)
public CompletableFuture<Void> acknowledgeCumulativeAsync(MessageId messageId)
acknowledgeCumulativeAsync in interface Consumer<T>public CompletableFuture<Void> acknowledgeCumulativeAsync(MessageId messageId, Transaction txn)
public void negativeAcknowledge(Message<?> message)
negativeAcknowledge in interface Consumer<T>protected CompletableFuture<Void> doAcknowledgeWithTxn(MessageId messageId, PulsarApi.CommandAck.AckType ackType, Map<String,Long> properties, TransactionImpl txn)
protected abstract CompletableFuture<Void> doAcknowledge(MessageId messageId, PulsarApi.CommandAck.AckType ackType, Map<String,Long> properties, TransactionImpl txn)
public void negativeAcknowledge(Messages<?> messages)
negativeAcknowledge in interface Consumer<T>public void unsubscribe()
throws PulsarClientException
unsubscribe in interface Consumer<T>PulsarClientExceptionpublic abstract CompletableFuture<Void> unsubscribeAsync()
unsubscribeAsync in interface Consumer<T>public void close()
throws PulsarClientException
close in interface Closeableclose in interface AutoCloseableclose in interface Consumer<T>PulsarClientExceptionpublic abstract CompletableFuture<Void> closeAsync()
closeAsync in interface Consumer<T>public MessageId getLastMessageId() throws PulsarClientException
getLastMessageId in interface Consumer<T>PulsarClientExceptionpublic abstract CompletableFuture<MessageId> getLastMessageIdAsync()
getLastMessageIdAsync in interface Consumer<T>protected PulsarApi.CommandSubscribe.SubType getSubType()
public abstract int getAvailablePermits()
public abstract int numMessagesInQueue()
public CompletableFuture<Consumer<T>> subscribeFuture()
public String getSubscription()
getSubscription in interface Consumer<T>public String getConsumerName()
getConsumerName in interface Consumer<T>protected abstract void redeliverUnacknowledgedMessages(Set<MessageId> messageIds)
protected void setMaxReceiverQueueSize(int newSize)
protected void onAcknowledgeCumulative(MessageId messageId, Throwable exception)
protected boolean enqueueMessageAndCheckBatchReceive(Message<T> message)
protected boolean hasEnoughMessagesForBatchReceive()
protected void notifyPendingBatchReceivedCallBack()
protected void notifyPendingBatchReceivedCallBack(ConsumerBase.OpBatchReceive<T> opBatchReceive)
protected abstract void messageProcessed(Message<?> msg)
public void run(io.netty.util.Timeout timeout)
throws Exception
run in interface io.netty.util.TimerTaskExceptionprotected MessagesImpl<T> getNewMessagesImpl()
protected boolean hasPendingBatchReceive()
protected abstract void completeOpBatchReceive(ConsumerBase.OpBatchReceive<T> op)
protected boolean changeToReadyState()
protected boolean changeToRegisteringSchemaState()
protected org.apache.pulsar.client.impl.HandlerState.State getState()
protected void setState(org.apache.pulsar.client.impl.HandlerState.State s)
protected org.apache.pulsar.client.impl.HandlerState.State getAndUpdateState(UnaryOperator<org.apache.pulsar.client.impl.HandlerState.State> updater)
public PulsarClientImpl getClient()
Copyright © 2017–2020 Apache Software Foundation. All rights reserved.