Class MessageDeduplication


  • public class MessageDeduplication
    extends java.lang.Object
    Class that contains all the logic to control and perform the deduplication on the broker side.
    • Constructor Detail

      • MessageDeduplication

        public MessageDeduplication​(PulsarService pulsar,
                                    PersistentTopic topic,
                                    org.apache.bookkeeper.mledger.ManagedLedger managedLedger)
    • Method Detail

      • getStatus

        public org.apache.pulsar.broker.service.persistent.MessageDeduplication.Status getStatus()
      • checkStatus

        public java.util.concurrent.CompletableFuture<java.lang.Void> checkStatus()
        Check the status of deduplication. If the configuration has changed, it will enable/disable deduplication, returning a future to track the completion of the task
      • isEnabled

        public boolean isEnabled()
      • isDuplicate

        public MessageDeduplication.MessageDupStatus isDuplicate​(Topic.PublishContext publishContext,
                                                                 io.netty.buffer.ByteBuf headersAndPayload)
        Assess whether the message was already stored in the topic.
        Returns:
        true if the message should be published or false if it was recognized as a duplicate
      • recordMessagePersisted

        public void recordMessagePersisted​(Topic.PublishContext publishContext,
                                           org.apache.bookkeeper.mledger.impl.PositionImpl position)
        Call this method whenever a message is persisted to get the chance to trigger a snapshot.
      • resetHighestSequenceIdPushed

        public void resetHighestSequenceIdPushed()
      • producerAdded

        public void producerAdded​(java.lang.String producerName)
        Topic will call this method whenever a producer connects.
      • producerRemoved

        public void producerRemoved​(java.lang.String producerName)
        Topic will call this method whenever a producer disconnects.
      • purgeInactiveProducers

        public void purgeInactiveProducers()
        Remove from hash maps all the producers that were inactive for more than the configured amount of time.
      • getLastPublishedSequenceId

        public long getLastPublishedSequenceId​(java.lang.String producerName)
      • takeSnapshot

        public void takeSnapshot()