Class PersistentSubscription
java.lang.Object
org.apache.pulsar.broker.service.AbstractSubscription
org.apache.pulsar.broker.service.persistent.PersistentSubscription
- All Implemented Interfaces:
MessageExpirer,Subscription
- Direct Known Subclasses:
PulsarCompactorSubscription
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final 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, ManagedCursor cursor, boolean replicated) PersistentSubscription(PersistentTopic topic, String subscriptionName, ManagedCursor cursor, boolean replicated, Map<String, String> subscriptionProperties) -
Method Summary
Modifier and TypeMethodDescriptionvoidacknowledgeMessage(List<Position> positions, org.apache.pulsar.common.api.proto.CommandAck.AckType ackType, Map<String, Long> properties) addConsumer(Consumer consumer) voidaddUnAckedMessages(int unAckMessages) analyzeBacklog(Optional<Position> position) booleanbooleanbooleancheckIsCanDeleteConsumerPendingAck(Position position) org.apache.pulsar.common.stats.PositionInPendingAckStatscheckPositionInPendingAckState(Position position, Integer batchIndex) close(boolean disconnectConsumers, Optional<BrokerLookupData> assignedBrokerLookupData) Fence this subscription and optionally disconnect all consumers.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(Optional<BrokerLookupData> assignedBrokerLookupData) Disconnect all consumers from this subscription.doUnsubscribe(Consumer consumer) Handle unsubscribe command from the client API Check with the dispatcher is this consumer can proceed with unsubscribe.doUnsubscribe(Consumer consumer, boolean force) 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(Position position) doublegetName()longlonggetNumberOfEntriesInBacklog(boolean getPreciseBacklog) longgetPositionInPendingAck(Position position) CompletableFuture<org.apache.pulsar.common.policies.data.stats.SubscriptionStatsImpl>getStatsAsync(GetStatsOptions getStatsOptions) 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()booleanbooleanvoidmergeCursorProperties(Map<String, Long> userProperties) Return a merged map that contains the cursor properties specified by used (eg.peekNthMessage(int messagePosition) voidprocessReplicatedSubscriptionSnapshot(org.apache.pulsar.common.api.proto.ReplicatedSubscriptionsSnapshot snapshot) voidredeliverUnacknowledgedMessages(Consumer consumer, long consumerEpoch) voidredeliverUnacknowledgedMessages(Consumer consumer, List<Position> positions) voidremoveConsumer(Consumer consumer, boolean isResetCursor) resetCursor(long timestamp) resetCursor(Position finalPosition) voidResume subscription after topic deletion or close failure.booleansetReplicated(boolean replicated) skipMessages(int numMessagesToSkip) voidsyncBatchPositionBitSetForPendingAck(Position position) toString()transactionCumulativeAcknowledge(org.apache.pulsar.client.api.transaction.TxnID txnId, List<Position> positions) transactionIndividualAcknowledge(org.apache.pulsar.client.api.transaction.TxnID txnId, List<org.apache.commons.lang3.tuple.MutablePair<Position, Integer>> positions) voidupdateSubscriptionProperties(Map<String, String> subscriptionProperties) Methods inherited from class org.apache.pulsar.broker.service.AbstractSubscription
checkForConsumerCompatibilityErrorWithDispatcher, 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
-
dispatcher
-
topicName
-
subName
-
fullName
-
-
Constructor Details
-
PersistentSubscription
public PersistentSubscription(PersistentTopic topic, String subscriptionName, ManagedCursor cursor, boolean replicated) -
PersistentSubscription
public PersistentSubscription(PersistentTopic topic, String subscriptionName, ManagedCursor cursor, boolean replicated, Map<String, String> subscriptionProperties)
-
-
Method Details
-
updateLastMarkDeleteAdvancedTimestamp
public void updateLastMarkDeleteAdvancedTimestamp() -
interceptor
-
getName
-
getTopic
-
isReplicated
public boolean isReplicated() -
setReplicated
public boolean setReplicated(boolean replicated) -
addConsumer
-
removeConsumer
- Throws:
BrokerServiceException
-
deactivateCursor
public void deactivateCursor() -
consumerFlow
-
acknowledgeMessage
-
transactionIndividualAcknowledge
public CompletableFuture<Void> transactionIndividualAcknowledge(org.apache.pulsar.client.api.transaction.TxnID txnId, List<org.apache.commons.lang3.tuple.MutablePair<Position, Integer>> positions) -
transactionCumulativeAcknowledge
public CompletableFuture<Void> transactionCumulativeAcknowledge(org.apache.pulsar.client.api.transaction.TxnID txnId, List<Position> positions) -
toString
-
getTopicName
-
getType
public org.apache.pulsar.common.api.proto.CommandSubscribe.SubType getType() -
getTypeString
-
analyzeBacklog
-
clearBacklog
-
skipMessages
-
resetCursor
-
resetCursor
-
peekNthMessage
-
getNumberOfEntriesInBacklog
public long getNumberOfEntriesInBacklog(boolean getPreciseBacklog) -
getDispatcher
-
getNumberOfEntriesSinceFirstNotAckedMessage
public long getNumberOfEntriesSinceFirstNotAckedMessage() -
getTotalNonContiguousDeletedMessagesRange
public int getTotalNonContiguousDeletedMessagesRange() -
disconnect
Disconnect all consumers from this subscription.- Returns:
- CompletableFuture indicating the completion of the operation.
-
close
public CompletableFuture<Void> close(boolean disconnectConsumers, Optional<BrokerLookupData> assignedBrokerLookupData) Fence this subscription and optionally disconnect all consumers.- Returns:
- CompletableFuture indicating the completion of the operation.
-
resumeAfterFence
public void resumeAfterFence()Resume subscription after topic deletion or close failure. -
delete
Delete the subscription by closing and deleting its managed cursor if no consumers are connected to it. Handle unsubscribe call from admin layer.- Returns:
- CompletableFuture indicating the completion of delete operation
-
deleteForcefully
Forcefully close all consumers and deletes the subscription.- Returns:
-
doUnsubscribe
Handle unsubscribe command from the client API Check with the dispatcher is this consumer can proceed with unsubscribe.- Parameters:
consumer- consumer object that is initiating the unsubscribe operation- Returns:
- CompletableFuture indicating the completion of unsubscribe operation
-
doUnsubscribe
Handle unsubscribe command from the client API Check with the dispatcher is this consumer can proceed with unsubscribe.- Parameters:
consumer- consumer object that is initiating the unsubscribe operationforce- unsubscribe forcefully by disconnecting consumers and closing subscription- Returns:
- CompletableFuture indicating the completion of unsubscribe operation
-
getConsumers
-
expireMessages
public boolean expireMessages(int messageTTLInSeconds) -
expireMessages
-
getExpiredMessageRate
public double getExpiredMessageRate() -
getExpiryMonitor
-
estimateBacklogSize
public long estimateBacklogSize() -
getStatsAsync
public CompletableFuture<org.apache.pulsar.common.policies.data.stats.SubscriptionStatsImpl> getStatsAsync(GetStatsOptions getStatsOptions) -
redeliverUnacknowledgedMessages
-
redeliverUnacknowledgedMessages
-
addUnAckedMessages
public void addUnAckedMessages(int unAckMessages) -
getNumberOfEntriesDelayed
public long getNumberOfEntriesDelayed() -
markTopicWithBatchMessagePublished
public void markTopicWithBatchMessagePublished() -
isSubscriptionMigrated
public boolean isSubscriptionMigrated() -
getSubscriptionProperties
-
getPositionInPendingAck
-
updateSubscriptionProperties
public CompletableFuture<Void> updateSubscriptionProperties(Map<String, String> subscriptionProperties) -
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) -
endTxn
public CompletableFuture<Void> endTxn(long txnidMostBits, long txnidLeastBits, int txnAction, long lowWaterMark) -
getCursor
-
syncBatchPositionBitSetForPendingAck
-
checkIsCanDeleteConsumerPendingAck
-
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
-