Package org.apache.pulsar.broker.service
Class Consumer
java.lang.Object
org.apache.pulsar.broker.service.Consumer
A Consumer is a consumer currently connected and associated with a Subscription.
-
Constructor Summary
ConstructorsConstructorDescriptionConsumer(Subscription subscription, org.apache.pulsar.common.api.proto.CommandSubscribe.SubType subType, String topicName, long consumerId, int priorityLevel, String consumerName, boolean isDurable, TransportCnx cnx, String appId, Map<String, String> metadata, boolean readCompacted, org.apache.pulsar.common.api.proto.KeySharedMeta keySharedMeta, org.apache.pulsar.client.api.MessageId startMessageId, long consumerEpoch) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the consumer if: a.voidclose(boolean isResetCursor) cnx()longvoidvoiddisconnect(boolean isResetCursor) voiddoUnsubscribe(long requestId) booleanvoidflowPermits(int additionalNumberOfMessages) intintreturn 0 if there is no entry dispatched yet.longorg.apache.pulsar.common.api.proto.KeySharedMetaintlongorg.apache.pulsar.common.util.collections.ConcurrentLongLongPairHashMapintorg.apache.pulsar.client.api.MessageIdorg.apache.pulsar.common.policies.data.stats.ConsumerStatsImplgetStats()intinthashCode()booleanbooleanbooleanmessageAcked(org.apache.pulsar.common.api.proto.CommandAck ack) voidbooleanvoidredeliverUnacknowledgedMessages(long consumerEpoch) voidredeliverUnacknowledgedMessages(List<org.apache.pulsar.common.api.proto.MessageIdData> messageIds) io.netty.util.concurrent.Future<Void>sendMessages(List<? extends org.apache.bookkeeper.mledger.Entry> entries, EntryBatchSizes batchSizes, EntryBatchIndexesAcks batchIndexesAcks, int totalMessages, long totalBytes, long totalChunkedMessages, RedeliveryTracker redeliveryTracker) io.netty.util.concurrent.Future<Void>sendMessages(List<? extends org.apache.bookkeeper.mledger.Entry> entries, EntryBatchSizes batchSizes, EntryBatchIndexesAcks batchIndexesAcks, int totalMessages, long totalBytes, long totalChunkedMessages, RedeliveryTracker redeliveryTracker, long epoch) Dispatch a list of entries to the consumer.voidsetReadPositionWhenJoining(org.apache.bookkeeper.mledger.impl.PositionImpl readPositionWhenJoining) org.apache.pulsar.common.api.proto.CommandSubscribe.SubTypesubType()toString()voidvoidupdateStats(org.apache.pulsar.common.policies.data.stats.ConsumerStatsImpl consumerStats)
-
Constructor Details
-
Method Details
-
subType
public org.apache.pulsar.common.api.proto.CommandSubscribe.SubType subType() -
consumerId
public long consumerId() -
consumerName
-
readCompacted
public boolean readCompacted() -
sendMessages
public io.netty.util.concurrent.Future<Void> sendMessages(List<? extends org.apache.bookkeeper.mledger.Entry> entries, EntryBatchSizes batchSizes, EntryBatchIndexesAcks batchIndexesAcks, int totalMessages, long totalBytes, long totalChunkedMessages, RedeliveryTracker redeliveryTracker) -
sendMessages
public io.netty.util.concurrent.Future<Void> sendMessages(List<? extends org.apache.bookkeeper.mledger.Entry> entries, EntryBatchSizes batchSizes, EntryBatchIndexesAcks batchIndexesAcks, int totalMessages, long totalBytes, long totalChunkedMessages, RedeliveryTracker redeliveryTracker, long epoch) Dispatch a list of entries to the consumer.
It is also responsible to release entries data and recycle entries object.- Returns:
- a SendMessageInfo object that contains the detail of what was sent to consumer
-
isWritable
public boolean isWritable() -
close
Close the consumer if: a. the connection is dropped b. connection is open (graceful close) and there are no pending message acks- Throws:
BrokerServiceException
-
close
- Throws:
BrokerServiceException
-
disconnect
public void disconnect() -
disconnect
public void disconnect(boolean isResetCursor) -
doUnsubscribe
public void doUnsubscribe(long requestId) -
messageAcked
-
flowPermits
public void flowPermits(int additionalNumberOfMessages) -
getAvailablePermits
public int getAvailablePermits() -
getAvgMessagesPerEntry
public int getAvgMessagesPerEntry()return 0 if there is no entry dispatched yet. -
isBlocked
public boolean isBlocked() -
reachedEndOfTopic
public void reachedEndOfTopic() -
updateRates
public void updateRates() -
updateStats
public void updateStats(org.apache.pulsar.common.policies.data.stats.ConsumerStatsImpl consumerStats) -
getStats
public org.apache.pulsar.common.policies.data.stats.ConsumerStatsImpl getStats() -
getMsgOutCounter
public long getMsgOutCounter() -
getBytesOutCounter
public long getBytesOutCounter() -
getUnackedMessages
public int getUnackedMessages() -
toString
-
checkPermissionsAsync
-
equals
-
hashCode
public int hashCode() -
getPendingAcks
public org.apache.pulsar.common.util.collections.ConcurrentLongLongPairHashMap getPendingAcks() -
getPriorityLevel
public int getPriorityLevel() -
redeliverUnacknowledgedMessages
public void redeliverUnacknowledgedMessages(long consumerEpoch) -
redeliverUnacknowledgedMessages
public void redeliverUnacknowledgedMessages(List<org.apache.pulsar.common.api.proto.MessageIdData> messageIds) -
getSubscription
-
isPreciseDispatcherFlowControl
public boolean isPreciseDispatcherFlowControl() -
setReadPositionWhenJoining
public void setReadPositionWhenJoining(org.apache.bookkeeper.mledger.impl.PositionImpl readPositionWhenJoining) -
getMaxUnackedMessages
public int getMaxUnackedMessages() -
cnx
-
getClientAddress
-
getStartMessageId
public org.apache.pulsar.client.api.MessageId getStartMessageId() -
getMetadata
-