Package org.apache.pulsar.client.impl
Class MultiTopicsConsumerImpl<T>
java.lang.Object
org.apache.pulsar.client.impl.ConsumerBase<T>
org.apache.pulsar.client.impl.MultiTopicsConsumerImpl<T>
- All Implemented Interfaces:
Closeable,AutoCloseable,Consumer<T>,MessageAcknowledger
- Direct Known Subclasses:
PatternMultiTopicsConsumerImpl
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.pulsar.client.impl.ConsumerBase
ConsumerBase.OpBatchReceive<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final PulsarClientImplprotected final ConcurrentHashMap<String,ConsumerImpl<T>> static final Stringprotected final ConcurrentHashMap<String,Integer> protected final ConcurrentLinkedQueue<ConsumerImpl<T>>protected URIprotected final StringFields inherited from class org.apache.pulsar.client.impl.ConsumerBase
batchReceivePolicy, batchReceiveTimeout, conf, CONSUMER_EPOCH, consumerEpoch, consumerEventListener, consumerName, CURRENT_RECEIVER_QUEUE_SIZE_UPDATER, executorProvider, externalPinnedExecutor, incomingMessagesSize, incomingQueueLock, INITIAL_RECEIVER_QUEUE_SIZE, interceptors, internalPinnedExecutor, listener, maxReceiverQueueSize, MEMORY_THRESHOLD_FOR_RECEIVER_QUEUE_SIZE_EXPANSION, MESSAGE_LISTENER_QUEUE_SIZE_UPDATER, messageListenerExecutor, messageListenerQueueSize, pendingBatchReceives, pendingReceives, scaleReceiverQueueHint, schema, subscribeFuture, subscription, unAckedChunkedMessageIdSequenceMap, unAckedMessageTracker -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanprotected booleanprotected booleanprotected booleancompareAndSetState(org.apache.pulsar.client.impl.HandlerState.State expect, org.apache.pulsar.client.impl.HandlerState.State update) protected voidstatic <T> MultiTopicsConsumerImpl<T>createPartitionedConsumer(PulsarClientImpl client, ConsumerConfigurationData<T> conf, ExecutorProvider executorProvider, CompletableFuture<Consumer<T>> subscribeFuture, int numPartitions, Schema<T> schema, ConsumerInterceptors<T> interceptors) protected CompletableFuture<Void>doAcknowledge(List<MessageId> messageIdList, CommandAck.AckType ackType, Map<String, Long> properties, TransactionImpl txn) protected CompletableFuture<Void>doAcknowledge(MessageId messageId, CommandAck.AckType ackType, Map<String, Long> properties, TransactionImpl txnImpl) protected CompletableFuture<Void>doReconsumeLater(Message<?> message, CommandAck.AckType ackType, Map<String, String> customProperties, long delayTime, TimeUnit unit) protected org.apache.pulsar.client.impl.HandlerState.StategetAndUpdateState(UnaryOperator<org.apache.pulsar.client.impl.HandlerState.State> updater) intlongDeprecated.io.netty.util.Timeoutprotected org.apache.pulsar.client.impl.HandlerState.StategetState()getStats()protected voidhandleSubscribeOneTopicError(String topicName, Throwable error, CompletableFuture<Void> subscribeFuture) booleanbooleanprotected CompletableFuture<Messages<T>>internalReceive(long timeout, TimeUnit unit) protected CompletableFuture<Message<T>>booleanstatic booleanisIllegalMultiTopicsMessageId(MessageId messageId) protected voidmessageProcessed(Message<?> msg) intvoidnegativeAcknowledge(Message<?> message) voidnegativeAcknowledge(MessageId messageId) intvoidpause()voidvoidredeliverUnacknowledgedMessages(Set<MessageId> messageIds) Redelivers the given unacknowledged messages.voidresume()voidseek(long timestamp) voidvoidseekAsync(long timestamp) protected voidsetCurrentReceiverQueueSize(int newSize) Update the size of the consumer receive queue.protected voidsetRedirectedClusterURI(String serviceUrl, String serviceUrlTls) protected voidsetState(org.apache.pulsar.client.impl.HandlerState.State s) subscribeAsync(String topicName, boolean createTopicIfDoesNotExist) Subscribe one more given topic.voidtryAcknowledgeMessage(Message<T> msg) unsubscribeAsync(String topicName) protected voidMethods inherited from class org.apache.pulsar.client.impl.ConsumerBase
acknowledge, acknowledge, acknowledge, acknowledge, acknowledgeAsync, acknowledgeAsync, acknowledgeAsync, acknowledgeAsync, acknowledgeAsync, acknowledgeAsync, acknowledgeAsync, acknowledgeCumulative, acknowledgeCumulative, acknowledgeCumulativeAsync, acknowledgeCumulativeAsync, acknowledgeCumulativeAsync, batchReceive, batchReceiveAsync, beforeConsume, callMessageListener, canEnqueueMessage, clearIncomingMessages, close, completePendingBatchReceive, completePendingReceive, decreaseIncomingMessageSize, doAcknowledgeWithTxn, doAcknowledgeWithTxn, enqueueMessageAndCheckBatchReceive, expectMoreIncomingMessages, failPendingReceive, getConsumerName, getCurrentReceiverQueueSize, getIncomingMessageSize, getLastMessageId, getLastMessageIds, getNewMessagesImpl, getSubscription, getSubType, getTopic, getTotalIncomingMessages, hasBatchReceiveTimeout, hasEnoughMessagesForBatchReceive, hasNextPendingReceive, hasPendingBatchReceive, increaseIncomingMessageSize, initReceiverQueueSize, isSingleMessageAcked, isValidConsumerEpoch, negativeAcknowledge, nextPendingReceive, notifyPendingBatchReceivedCallBack, notifyPendingBatchReceivedCallBack, onAcknowledge, onAcknowledge, onAcknowledgeCumulative, onAcknowledgeCumulative, onAckTimeoutSend, onNegativeAcksSend, onPartitionsChange, peekMessageKey, receive, receive, receiveAsync, reconsumeLater, reconsumeLater, reconsumeLater, reconsumeLaterAsync, reconsumeLaterAsync, reconsumeLaterAsync, reconsumeLaterCumulative, reconsumeLaterCumulativeAsync, reconsumeLaterCumulativeAsync, reduceCurrentReceiverQueueSize, resetIncomingMessageSize, subscribeFuture, toString, trackUnAckedMsgIfNoListener, triggerBatchReceiveTimeoutTask, tryTriggerListener, unsubscribe
-
Field Details
-
DUMMY_TOPIC_NAME_PREFIX
- See Also:
-
consumers
-
partitionedTopics
-
pausedConsumers
-
client
-
topic
-
redirectedClusterURI
-
-
Method Details
-
messageProcessed
- Specified by:
messageProcessedin classConsumerBase<T>
-
minReceiverQueueSize
public int minReceiverQueueSize()- Specified by:
minReceiverQueueSizein classConsumerBase<T>
-
internalReceive
- Specified by:
internalReceivein classConsumerBase<T>- Throws:
PulsarClientException
-
internalReceive
- Specified by:
internalReceivein classConsumerBase<T>- Throws:
PulsarClientException
-
internalBatchReceive
- Specified by:
internalBatchReceivein classConsumerBase<T>- Throws:
PulsarClientException
-
internalBatchReceiveAsync
- Specified by:
internalBatchReceiveAsyncin classConsumerBase<T>
-
internalReceiveAsync
- Specified by:
internalReceiveAsyncin classConsumerBase<T>
-
doAcknowledge
protected CompletableFuture<Void> doAcknowledge(MessageId messageId, CommandAck.AckType ackType, Map<String, Long> properties, TransactionImpl txnImpl) - Specified by:
doAcknowledgein classConsumerBase<T>
-
doAcknowledge
protected CompletableFuture<Void> doAcknowledge(List<MessageId> messageIdList, CommandAck.AckType ackType, Map<String, Long> properties, TransactionImpl txn) - Specified by:
doAcknowledgein classConsumerBase<T>
-
doReconsumeLater
protected CompletableFuture<Void> doReconsumeLater(Message<?> message, CommandAck.AckType ackType, Map<String, String> customProperties, long delayTime, TimeUnit unit) - Specified by:
doReconsumeLaterin classConsumerBase<T>
-
negativeAcknowledge
-
negativeAcknowledge
- Specified by:
negativeAcknowledgein interfaceConsumer<T>- Overrides:
negativeAcknowledgein classConsumerBase<T>
-
unsubscribeAsync
- Specified by:
unsubscribeAsyncin interfaceConsumer<T>- Specified by:
unsubscribeAsyncin classConsumerBase<T>
-
closeAsync
- Specified by:
closeAsyncin interfaceConsumer<T>- Specified by:
closeAsyncin classConsumerBase<T>
-
isConnected
public boolean isConnected() -
redeliverUnacknowledgedMessages
public void redeliverUnacknowledgedMessages() -
redeliverUnacknowledgedMessages
Description copied from class:ConsumerBaseRedelivers the given unacknowledged messages. In Failover mode, the request is ignored if the consumer is not active for the given topic. In Shared mode, the consumers messages to be redelivered are distributed across all the connected consumers. This is a non blocking call and doesn't throw an exception. In case the connection breaks, the messages are redelivered after reconnect.- Specified by:
redeliverUnacknowledgedMessagesin classConsumerBase<T>
-
updateAutoScaleReceiverQueueHint
protected void updateAutoScaleReceiverQueueHint()- Specified by:
updateAutoScaleReceiverQueueHintin classConsumerBase<T>
-
completeOpBatchReceive
- Specified by:
completeOpBatchReceivein classConsumerBase<T>
-
seek
- Throws:
PulsarClientException
-
seek
- Throws:
PulsarClientException
-
seek
- Throws:
PulsarClientException
-
seekAsync
-
seekAsync
-
seekAsync
-
getAvailablePermits
public int getAvailablePermits()- Specified by:
getAvailablePermitsin classConsumerBase<T>
-
hasReachedEndOfTopic
public boolean hasReachedEndOfTopic() -
hasMessageAvailable
- Throws:
PulsarClientException
-
hasMessageAvailableAsync
-
numMessagesInQueue
public int numMessagesInQueue()- Specified by:
numMessagesInQueuein classConsumerBase<T>
-
getStats
-
getUnAckedMessageTracker
- Overrides:
getUnAckedMessageTrackerin classConsumerBase<T>
-
subscribeAsync
Subscribe one more given topic.- Parameters:
topicName- topic name without the partition suffix.
-
createPartitionedConsumer
public static <T> MultiTopicsConsumerImpl<T> createPartitionedConsumer(PulsarClientImpl client, ConsumerConfigurationData<T> conf, ExecutorProvider executorProvider, CompletableFuture<Consumer<T>> subscribeFuture, int numPartitions, Schema<T> schema, ConsumerInterceptors<T> interceptors) -
handleSubscribeOneTopicError
protected void handleSubscribeOneTopicError(String topicName, Throwable error, CompletableFuture<Void> subscribeFuture) -
unsubscribeAsync
-
getPartitionedTopics
-
getPartitions
-
getConsumers
-
pause
public void pause() -
resume
public void resume() -
getLastDisconnectedTimestamp
public long getLastDisconnectedTimestamp() -
getPartitionsAutoUpdateTimeout
public io.netty.util.Timeout getPartitionsAutoUpdateTimeout() -
getLastMessageIdAsync
Deprecated.- Specified by:
getLastMessageIdAsyncin interfaceConsumer<T>- Specified by:
getLastMessageIdAsyncin classConsumerBase<T>
-
getLastMessageIdsAsync
-
isIllegalMultiTopicsMessageId
-
tryAcknowledgeMessage
-
setCurrentReceiverQueueSize
protected void setCurrentReceiverQueueSize(int newSize) Description copied from class:ConsumerBaseUpdate the size of the consumer receive queue. SeeConsumerBuilder.receiverQueueSize(int).- Specified by:
setCurrentReceiverQueueSizein classConsumerBase<T>- Parameters:
newSize- new size of the receiver queue.
-
setRedirectedClusterURI
protected void setRedirectedClusterURI(String serviceUrl, String serviceUrlTls) throws URISyntaxException - Throws:
URISyntaxException
-
changeToReadyState
protected boolean changeToReadyState() -
compareAndSetState
protected boolean compareAndSetState(org.apache.pulsar.client.impl.HandlerState.State expect, org.apache.pulsar.client.impl.HandlerState.State update) -
changeToRegisteringSchemaState
protected boolean changeToRegisteringSchemaState() -
getState
protected org.apache.pulsar.client.impl.HandlerState.State getState() -
changeToConnecting
protected boolean changeToConnecting() -
setState
protected void setState(org.apache.pulsar.client.impl.HandlerState.State s) -
getAndUpdateState
protected org.apache.pulsar.client.impl.HandlerState.State getAndUpdateState(UnaryOperator<org.apache.pulsar.client.impl.HandlerState.State> updater) -
getClient
-