Class PersistentSubscription

    • Field Detail

      • cursor

        protected final org.apache.bookkeeper.mledger.ManagedCursor cursor
      • dispatcher

        protected volatile Dispatcher dispatcher
      • topicName

        protected final java.lang.String topicName
      • subName

        protected final java.lang.String subName
      • fullName

        protected final java.lang.String fullName
    • Constructor Detail

      • PersistentSubscription

        public PersistentSubscription​(PersistentTopic topic,
                                      java.lang.String subscriptionName,
                                      org.apache.bookkeeper.mledger.ManagedCursor cursor,
                                      boolean replicated)
      • PersistentSubscription

        public PersistentSubscription​(PersistentTopic topic,
                                      java.lang.String subscriptionName,
                                      org.apache.bookkeeper.mledger.ManagedCursor cursor,
                                      boolean replicated,
                                      java.util.Map<java.lang.String,​java.lang.String> subscriptionProperties)
    • Method Detail

      • updateLastMarkDeleteAdvancedTimestamp

        public void updateLastMarkDeleteAdvancedTimestamp()
      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface Subscription
      • setReplicated

        public boolean setReplicated​(boolean replicated)
      • addConsumer

        public java.util.concurrent.CompletableFuture<java.lang.Void> addConsumer​(Consumer consumer)
        Specified by:
        addConsumer in interface Subscription
      • deactivateCursor

        public void deactivateCursor()
      • acknowledgeMessage

        public void acknowledgeMessage​(java.util.List<org.apache.bookkeeper.mledger.Position> positions,
                                       org.apache.pulsar.common.api.proto.CommandAck.AckType ackType,
                                       java.util.Map<java.lang.String,​java.lang.Long> properties)
        Specified by:
        acknowledgeMessage in interface Subscription
      • transactionIndividualAcknowledge

        public java.util.concurrent.CompletableFuture<java.lang.Void> transactionIndividualAcknowledge​(org.apache.pulsar.client.api.transaction.TxnID txnId,
                                                                                                       java.util.List<org.apache.commons.lang3.tuple.MutablePair<org.apache.bookkeeper.mledger.impl.PositionImpl,​java.lang.Integer>> positions)
      • transactionCumulativeAcknowledge

        public java.util.concurrent.CompletableFuture<java.lang.Void> transactionCumulativeAcknowledge​(org.apache.pulsar.client.api.transaction.TxnID txnId,
                                                                                                       java.util.List<org.apache.bookkeeper.mledger.impl.PositionImpl> positions)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getType

        public org.apache.pulsar.common.api.proto.CommandSubscribe.SubType getType()
        Specified by:
        getType in interface Subscription
      • clearBacklog

        public java.util.concurrent.CompletableFuture<java.lang.Void> clearBacklog()
        Specified by:
        clearBacklog in interface Subscription
      • skipMessages

        public java.util.concurrent.CompletableFuture<java.lang.Void> skipMessages​(int numMessagesToSkip)
        Specified by:
        skipMessages in interface Subscription
      • resetCursor

        public java.util.concurrent.CompletableFuture<java.lang.Void> resetCursor​(long timestamp)
        Specified by:
        resetCursor in interface Subscription
      • resetCursor

        public java.util.concurrent.CompletableFuture<java.lang.Void> resetCursor​(org.apache.bookkeeper.mledger.Position position)
        Specified by:
        resetCursor in interface Subscription
      • peekNthMessage

        public java.util.concurrent.CompletableFuture<org.apache.bookkeeper.mledger.Entry> peekNthMessage​(int messagePosition)
        Specified by:
        peekNthMessage in interface Subscription
      • getNumberOfEntriesSinceFirstNotAckedMessage

        public long getNumberOfEntriesSinceFirstNotAckedMessage()
      • getTotalNonContiguousDeletedMessagesRange

        public int getTotalNonContiguousDeletedMessagesRange()
      • close

        public java.util.concurrent.CompletableFuture<java.lang.Void> close()
        Close the cursor ledger for this subscription. Requires that there are no active consumers on the dispatcher
        Specified by:
        close in interface Subscription
        Returns:
        CompletableFuture indicating the completion of delete operation
      • disconnect

        public java.util.concurrent.CompletableFuture<java.lang.Void> disconnect()
        Disconnect all consumers attached to the dispatcher and close this subscription.
        Specified by:
        disconnect in interface Subscription
        Returns:
        CompletableFuture indicating the completion of disconnect operation
      • delete

        public java.util.concurrent.CompletableFuture<java.lang.Void> 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:
        delete in interface Subscription
        Returns:
        CompletableFuture indicating the completion of delete operation
      • deleteForcefully

        public java.util.concurrent.CompletableFuture<java.lang.Void> deleteForcefully()
        Forcefully close all consumers and deletes the subscription.
        Specified by:
        deleteForcefully in interface Subscription
        Returns:
      • doUnsubscribe

        public java.util.concurrent.CompletableFuture<java.lang.Void> doUnsubscribe​(Consumer consumer)
        Handle unsubscribe command from the client API Check with the dispatcher is this consumer can proceed with unsubscribe.
        Specified by:
        doUnsubscribe in interface Subscription
        Parameters:
        consumer - consumer object that is initiating the unsubscribe operation
        Returns:
        CompletableFuture indicating the completion of unsubscribe operation
      • expireMessages

        public boolean expireMessages​(int messageTTLInSeconds)
        Specified by:
        expireMessages in interface Subscription
      • expireMessages

        public boolean expireMessages​(org.apache.bookkeeper.mledger.Position position)
        Specified by:
        expireMessages in interface Subscription
      • estimateBacklogSize

        public long estimateBacklogSize()
      • getStats

        public org.apache.pulsar.common.policies.data.stats.SubscriptionStatsImpl getStats​(java.lang.Boolean getPreciseBacklog,
                                                                                           boolean subscriptionBacklogSize,
                                                                                           boolean getEarliestTimeInBacklog)
      • getPositionInPendingAck

        public org.apache.bookkeeper.mledger.impl.PositionImpl getPositionInPendingAck​(org.apache.bookkeeper.mledger.impl.PositionImpl position)
      • updateSubscriptionProperties

        public java.util.concurrent.CompletableFuture<java.lang.Void> updateSubscriptionProperties​(java.util.Map<java.lang.String,​java.lang.String> subscriptionProperties)
        Specified by:
        updateSubscriptionProperties in interface Subscription
      • mergeCursorProperties

        protected java.util.Map<java.lang.String,​java.lang.Long> mergeCursorProperties​(java.util.Map<java.lang.String,​java.lang.Long> userProperties)
        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:
        processReplicatedSubscriptionSnapshot in interface Subscription
      • endTxn

        public java.util.concurrent.CompletableFuture<java.lang.Void> endTxn​(long txnidMostBits,
                                                                             long txnidLeastBits,
                                                                             int txnAction,
                                                                             long lowWaterMark)
        Specified by:
        endTxn in interface Subscription
      • getCursor

        public org.apache.bookkeeper.mledger.ManagedCursor getCursor()
      • 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()
      • checkAndUnblockIfStuck

        public boolean checkAndUnblockIfStuck()
      • getTransactionInPendingAckStats

        public org.apache.pulsar.common.policies.data.TransactionInPendingAckStats getTransactionInPendingAckStats​(org.apache.pulsar.client.api.transaction.TxnID txnID)
      • getPendingAckManageLedger

        public java.util.concurrent.CompletableFuture<org.apache.bookkeeper.mledger.ManagedLedger> getPendingAckManageLedger()
      • checkIfPendingAckStoreInit

        public boolean checkIfPendingAckStoreInit()