Message deduplication
To use message deduplication in Pulsar, you need to configure your Pulsar brokers and clients.
You can enable or disable message deduplication at the namespace level or the topic level. By default, it is disabled on all namespaces or topics. You can enable it in the following ways:
- Enable deduplication for all namespaces/topics at the broker-level.
- Enable deduplication for a specific namespace with the interface.
- Enable deduplication for a specific topic with the
pulsar-admin topics
interface.
You can configure message deduplication in Pulsar using the broker.conf configuration file. The following deduplication-related parameters are available.
By default, message deduplication is disabled on all Pulsar namespaces/topics. To enable it on all namespaces/topics, set the brokerDeduplicationEnabled
parameter to true
and re-start the broker.
Though message deduplication is disabled by default at the broker level, you can enable message deduplication for a specific namespace or topic using the or the pulsar-admin topics set-deduplication command. You can use the --enable
/-e
flag and specify the namespace/topic.
The following example shows how to enable message deduplication at the namespace level.
Even if you enable message deduplication at the broker level, you can disable message deduplication for a specific namespace or topic using the or the pulsar-admin topics set-deduplication command. Use the /-d
flag and specify the namespace/topic.
The following example shows how to disable message deduplication at the namespace level.
- Set the message timeout to
0
(namely, no timeout).
The instructions for Java, Python, and C++ clients are different.
- Java clients
- Python clients
- C++ clients
To enable message deduplication on a , set the producer name using the producerName
setter, and set the timeout to 0
using the sendTimeout
setter.
To enable message deduplication on a Python producer, set the producer name using producer_name
, and set the timeout to 0
using send_timeout_millis
.
To enable message deduplication on a , set the producer name using producer_name
, and set the timeout to using send_timeout_millis
.