Class PersistentSubscription
java.lang.Object
org.apache.pulsar.broker.service.AbstractSubscription
org.apache.pulsar.broker.service.persistent.PersistentSubscription
- All Implemented Interfaces:
Subscription
- Direct Known Subclasses:
CompactorSubscription
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.apache.bookkeeper.mledger.ManagedCursorprotected Dispatcherprotected final Stringprotected final Stringprotected final PersistentTopicprotected final StringFields inherited from class org.apache.pulsar.broker.service.AbstractSubscription
bytesOutFromRemovedConsumers, msgOutFromRemovedConsumer -
Constructor Summary
ConstructorsConstructorDescriptionPersistentSubscription(PersistentTopic topic, String subscriptionName, org.apache.bookkeeper.mledger.ManagedCursor cursor, boolean replicated) PersistentSubscription(PersistentTopic topic, String subscriptionName, org.apache.bookkeeper.mledger.ManagedCursor cursor, boolean replicated, Map<String, String> subscriptionProperties) -
Method Summary
Modifier and TypeMethodDescriptionvoidacknowledgeMessage(List<org.apache.bookkeeper.mledger.Position> positions, org.apache.pulsar.common.api.proto.CommandAck.AckType ackType, Map<String, Long> properties) addConsumer(Consumer consumer) voidaddUnAckedMessages(int unAckMessages) analyzeBacklog(Optional<org.apache.bookkeeper.mledger.Position> position) booleanbooleanbooleancheckIsCanDeleteConsumerPendingAck(org.apache.bookkeeper.mledger.impl.PositionImpl position) org.apache.pulsar.common.stats.PositionInPendingAckStatscheckPositionInPendingAckState(org.apache.bookkeeper.mledger.impl.PositionImpl position, Integer batchIndex) close()Close the cursor ledger for this subscription.voidconsumerFlow(Consumer consumer, int additionalNumberOfMessages) voiddelete()Delete the subscription by closing and deleting its managed cursor if no consumers are connected to it.Forcefully close all consumers and deletes the subscription.Disconnect all consumers attached to the dispatcher and close this subscription.doUnsubscribe(Consumer consumer) Handle unsubscribe command from the client API Check with the dispatcher is this consumer can proceed with unsubscribe.endTxn(long txnidMostBits, long txnidLeastBits, int txnAction, long lowWaterMark) longbooleanexpireMessages(int messageTTLInSeconds) booleanexpireMessages(org.apache.bookkeeper.mledger.Position position) org.apache.bookkeeper.mledger.ManagedCursordoublegetName()longlonggetNumberOfEntriesInBacklog(boolean getPreciseBacklog) longCompletableFuture<org.apache.bookkeeper.mledger.ManagedLedger>org.apache.bookkeeper.mledger.impl.PositionImplgetPositionInPendingAck(org.apache.bookkeeper.mledger.impl.PositionImpl position) org.apache.pulsar.common.policies.data.stats.SubscriptionStatsImplgetStats(Boolean getPreciseBacklog, boolean subscriptionBacklogSize, boolean getEarliestTimeInBacklog) getTopic()intorg.apache.pulsar.common.policies.data.TransactionInPendingAckStatsgetTransactionInPendingAckStats(org.apache.pulsar.client.api.transaction.TxnID txnID) org.apache.pulsar.common.policies.data.TransactionPendingAckStatsgetTransactionPendingAckStats(boolean lowWaterMarks) org.apache.pulsar.common.api.proto.CommandSubscribe.SubTypegetType()booleanvoidmergeCursorProperties(Map<String, Long> userProperties) Return a merged map that contains the cursor properties specified by used (eg.CompletableFuture<org.apache.bookkeeper.mledger.Entry>peekNthMessage(int messagePosition) voidprocessReplicatedSubscriptionSnapshot(org.apache.pulsar.common.api.proto.ReplicatedSubscriptionsSnapshot snapshot) voidredeliverUnacknowledgedMessages(Consumer consumer, long consumerEpoch) voidredeliverUnacknowledgedMessages(Consumer consumer, List<org.apache.bookkeeper.mledger.impl.PositionImpl> positions) voidremoveConsumer(Consumer consumer, boolean isResetCursor) resetCursor(long timestamp) resetCursor(org.apache.bookkeeper.mledger.Position position) booleansetReplicated(boolean replicated) skipMessages(int numMessagesToSkip) voidsyncBatchPositionBitSetForPendingAck(org.apache.bookkeeper.mledger.impl.PositionImpl position) toString()transactionCumulativeAcknowledge(org.apache.pulsar.client.api.transaction.TxnID txnId, List<org.apache.bookkeeper.mledger.impl.PositionImpl> positions) transactionIndividualAcknowledge(org.apache.pulsar.client.api.transaction.TxnID txnId, List<org.apache.commons.lang3.tuple.MutablePair<org.apache.bookkeeper.mledger.impl.PositionImpl, Integer>> positions) voidupdateSubscriptionProperties(Map<String, String> subscriptionProperties) Methods inherited from class org.apache.pulsar.broker.service.AbstractSubscription
getBytesOutCounter, getMsgOutCounterMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.pulsar.broker.service.Subscription
getNumberOfSameAddressConsumers, removeConsumer
-
Field Details
-
topic
-
cursor
protected final org.apache.bookkeeper.mledger.ManagedCursor cursor -
dispatcher
-
topicName
-
subName
-
fullName
-
-
Constructor Details
-
PersistentSubscription
public PersistentSubscription(PersistentTopic topic, String subscriptionName, org.apache.bookkeeper.mledger.ManagedCursor cursor, boolean replicated) -
PersistentSubscription
public PersistentSubscription(PersistentTopic topic, String subscriptionName, org.apache.bookkeeper.mledger.ManagedCursor cursor, boolean replicated, Map<String, String> subscriptionProperties)
-
-
Method Details
-
updateLastMarkDeleteAdvancedTimestamp
public void updateLastMarkDeleteAdvancedTimestamp() -
interceptor
- Specified by:
interceptorin interfaceSubscription
-
getName
- Specified by:
getNamein interfaceSubscription
-
getTopic
- Specified by:
getTopicin interfaceSubscription
-
isReplicated
public boolean isReplicated()- Specified by:
isReplicatedin interfaceSubscription
-
setReplicated
public boolean setReplicated(boolean replicated) -
addConsumer
- Specified by:
addConsumerin interfaceSubscription
-
removeConsumer
- Specified by:
removeConsumerin interfaceSubscription- Throws:
BrokerServiceException
-
deactivateCursor
public void deactivateCursor() -
consumerFlow
- Specified by:
consumerFlowin interfaceSubscription
-
acknowledgeMessage
public void acknowledgeMessage(List<org.apache.bookkeeper.mledger.Position> positions, org.apache.pulsar.common.api.proto.CommandAck.AckType ackType, Map<String, Long> properties) - Specified by:
acknowledgeMessagein interfaceSubscription
-
transactionIndividualAcknowledge
public CompletableFuture<Void> transactionIndividualAcknowledge(org.apache.pulsar.client.api.transaction.TxnID txnId, List<org.apache.commons.lang3.tuple.MutablePair<org.apache.bookkeeper.mledger.impl.PositionImpl, Integer>> positions) -
transactionCumulativeAcknowledge
public CompletableFuture<Void> transactionCumulativeAcknowledge(org.apache.pulsar.client.api.transaction.TxnID txnId, List<org.apache.bookkeeper.mledger.impl.PositionImpl> positions) -
toString
-
getTopicName
- Specified by:
getTopicNamein interfaceSubscription
-
getType
public org.apache.pulsar.common.api.proto.CommandSubscribe.SubType getType()- Specified by:
getTypein interfaceSubscription
-
getTypeString
- Specified by:
getTypeStringin interfaceSubscription
-
analyzeBacklog
public CompletableFuture<AnalyzeBacklogResult> analyzeBacklog(Optional<org.apache.bookkeeper.mledger.Position> position) - Specified by:
analyzeBacklogin interfaceSubscription
-
clearBacklog
- Specified by:
clearBacklogin interfaceSubscription
-
skipMessages
- Specified by:
skipMessagesin interfaceSubscription
-
resetCursor
- Specified by:
resetCursorin interfaceSubscription
-
resetCursor
- Specified by:
resetCursorin interfaceSubscription
-
peekNthMessage
- Specified by:
peekNthMessagein interfaceSubscription
-
getNumberOfEntriesInBacklog
public long getNumberOfEntriesInBacklog(boolean getPreciseBacklog) - Specified by:
getNumberOfEntriesInBacklogin interfaceSubscription
-
getDispatcher
- Specified by:
getDispatcherin interfaceSubscription
-
getNumberOfEntriesSinceFirstNotAckedMessage
public long getNumberOfEntriesSinceFirstNotAckedMessage() -
getTotalNonContiguousDeletedMessagesRange
public int getTotalNonContiguousDeletedMessagesRange() -
close
Close the cursor ledger for this subscription. Requires that there are no active consumers on the dispatcher- Specified by:
closein interfaceSubscription- Returns:
- CompletableFuture indicating the completion of delete operation
-
disconnect
Disconnect all consumers attached to the dispatcher and close this subscription.- Specified by:
disconnectin interfaceSubscription- Returns:
- CompletableFuture indicating the completion of disconnect operation
-
delete
Delete the subscription by closing and deleting its managed cursor if no consumers are connected to it. Handle unsubscribe call from admin layer.- Specified by:
deletein interfaceSubscription- Returns:
- CompletableFuture indicating the completion of delete operation
-
deleteForcefully
Forcefully close all consumers and deletes the subscription.- Specified by:
deleteForcefullyin interfaceSubscription- Returns:
-
doUnsubscribe
Handle unsubscribe command from the client API Check with the dispatcher is this consumer can proceed with unsubscribe.- Specified by:
doUnsubscribein interfaceSubscription- Parameters:
consumer- consumer object that is initiating the unsubscribe operation- Returns:
- CompletableFuture indicating the completion of unsubscribe operation
-
getConsumers
- Specified by:
getConsumersin interfaceSubscription
-
expireMessages
public boolean expireMessages(int messageTTLInSeconds) - Specified by:
expireMessagesin interfaceSubscription
-
expireMessages
public boolean expireMessages(org.apache.bookkeeper.mledger.Position position) - Specified by:
expireMessagesin interfaceSubscription
-
getExpiredMessageRate
public double getExpiredMessageRate()- Specified by:
getExpiredMessageRatein interfaceSubscription
-
getExpiryMonitor
-
estimateBacklogSize
public long estimateBacklogSize() -
getStats
public org.apache.pulsar.common.policies.data.stats.SubscriptionStatsImpl getStats(Boolean getPreciseBacklog, boolean subscriptionBacklogSize, boolean getEarliestTimeInBacklog) -
redeliverUnacknowledgedMessages
- Specified by:
redeliverUnacknowledgedMessagesin interfaceSubscription
-
redeliverUnacknowledgedMessages
public void redeliverUnacknowledgedMessages(Consumer consumer, List<org.apache.bookkeeper.mledger.impl.PositionImpl> positions) - Specified by:
redeliverUnacknowledgedMessagesin interfaceSubscription
-
addUnAckedMessages
public void addUnAckedMessages(int unAckMessages) - Specified by:
addUnAckedMessagesin interfaceSubscription
-
getNumberOfEntriesDelayed
public long getNumberOfEntriesDelayed()- Specified by:
getNumberOfEntriesDelayedin interfaceSubscription
-
markTopicWithBatchMessagePublished
public void markTopicWithBatchMessagePublished()- Specified by:
markTopicWithBatchMessagePublishedin interfaceSubscription
-
getSubscriptionProperties
- Specified by:
getSubscriptionPropertiesin interfaceSubscription
-
getPositionInPendingAck
public org.apache.bookkeeper.mledger.impl.PositionImpl getPositionInPendingAck(org.apache.bookkeeper.mledger.impl.PositionImpl position) -
updateSubscriptionProperties
public CompletableFuture<Void> updateSubscriptionProperties(Map<String, String> subscriptionProperties) - Specified by:
updateSubscriptionPropertiesin interfaceSubscription
-
mergeCursorProperties
Return a merged map that contains the cursor properties specified by used (eg. when using compaction subscription) and the subscription properties. -
processReplicatedSubscriptionSnapshot
public void processReplicatedSubscriptionSnapshot(org.apache.pulsar.common.api.proto.ReplicatedSubscriptionsSnapshot snapshot) - Specified by:
processReplicatedSubscriptionSnapshotin interfaceSubscription
-
endTxn
public CompletableFuture<Void> endTxn(long txnidMostBits, long txnidLeastBits, int txnAction, long lowWaterMark) - Specified by:
endTxnin interfaceSubscription
-
getCursor
public org.apache.bookkeeper.mledger.ManagedCursor getCursor() -
getPendingAckHandle
-
syncBatchPositionBitSetForPendingAck
public void syncBatchPositionBitSetForPendingAck(org.apache.bookkeeper.mledger.impl.PositionImpl position) -
checkIsCanDeleteConsumerPendingAck
public boolean checkIsCanDeleteConsumerPendingAck(org.apache.bookkeeper.mledger.impl.PositionImpl position) -
getTransactionPendingAckStats
public org.apache.pulsar.common.policies.data.TransactionPendingAckStats getTransactionPendingAckStats(boolean lowWaterMarks) -
checkAndUnblockIfStuck
public boolean checkAndUnblockIfStuck() -
getTransactionInPendingAckStats
public org.apache.pulsar.common.policies.data.TransactionInPendingAckStats getTransactionInPendingAckStats(org.apache.pulsar.client.api.transaction.TxnID txnID) -
getPendingAckManageLedger
-
checkIfPendingAckStoreInit
public boolean checkIfPendingAckStoreInit() -
checkPositionInPendingAckState
public org.apache.pulsar.common.stats.PositionInPendingAckStats checkPositionInPendingAckState(org.apache.bookkeeper.mledger.impl.PositionImpl position, Integer batchIndex)
-