public abstract class ConsumerBase<T> extends Object implements Consumer<T>
| Modifier and Type | Field and Description |
|---|---|
protected PulsarClientImpl |
client |
protected ConsumerConfigurationData<T> |
conf |
protected ConsumerEventListener |
consumerEventListener |
protected String |
consumerName |
protected ConsumerInterceptors<T> |
interceptors |
protected MessageListener<T> |
listener |
protected ExecutorService |
listenerExecutor |
protected int |
maxReceiverQueueSize |
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, pause, redeliverUnacknowledgedMessages, resume, seek, 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 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 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 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> acknowledgeCumulativeAsync(Message<?> message)
acknowledgeCumulativeAsync in interface Consumer<T>public CompletableFuture<Void> acknowledgeAsync(MessageId messageId)
acknowledgeAsync in interface Consumer<T>public CompletableFuture<Void> acknowledgeCumulativeAsync(MessageId messageId)
acknowledgeCumulativeAsync in interface Consumer<T>protected abstract CompletableFuture<Void> doAcknowledge(MessageId messageId, PulsarApi.CommandAck.AckType ackType, Map<String,Long> properties)
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>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 changeToReadyState()
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–2019 Apache Software Foundation. All rights reserved.