Message deduplication

    Pulsar中启用消息去重,你必须同时配置 Pulsar broker 和客户端。

    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:

    • 在 broker 级别启用所有命名空间/主题的去重。
    • 通过pulsar-admin topics 命令设置命名空间启用去重。

    你可以通过broker.conf配置 Pulsar 启用消息去重。 下面是和去重有关的配置项。

    By default, message deduplication is disabled on all Pulsar namespaces/topics. 启用所有命名空间/主题的去重功能,需设置配置项brokerDeduplicationEnabledtrue并重启 broker。

    即使设置了brokerDeduplicationEnabled配置项,通过 Pulsar admin CLI 设置的值也会覆盖 broker 的配置。

    下面示例显示如何在命名空间级别启用去重。

    如果broker 级别启用了消息去重,你能够使用或者pulsar-admin topics set-deduplication命令禁用去重功能。 你能通过使用/-d标记并指定命名空间/主题禁用去重。

    下面示例显示如何在命名空间级别禁用去重。

    If you enable message deduplication in Pulsar brokers, you need complete the following tasks for your client producers:

    1. 指定生产者的名称。
    2. 设置消息超时为0(即无超时)。

    The instructions for Java, Python, and C++ clients are different.

    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.