tencent cloud

Feedback

Consumption Mode

Last updated: 2023-09-13 11:40:40
    This document describes the features and use cases of clustering consumption and broadcasting consumption in TDMQ for RocketMQ.

    Feature Overview

    Cluster consumption: if the cluster consumption mode is used, any message only needs to be processed by any consumer in the cluster.
    Broadcast consumption: if the broadcast consumption mode is used, each message will be pushed to all registered consumers in the cluster to ensure that the message is consumed by each consumer at least once.

    Use Cases

    Clustering consumption is suitable for scenarios where each message only needs to be processed once.
    Broadcasting consumption is suitable for scenarios where each message needs to be processed by each consumer in the cluster.

    Sample Codes

    Cluster subscription All consumers identified by the same group ID will evenly share messages for consumption. For example, if a topic has nine messages, and a group ID identifies three consumer instances, then each instance will consume only three messages evenly in the clustering consumption mode.
    // Set the cluster subscription mode (which is the default mode if you don't specify one)
    properties.put(PropertyKeyConst.MessageModel, PropertyValueConst.CLUSTERING);
    Broadcast subscription A message will be consumed once by all consumers identified by the same group ID. In the broadcasting consumption mode, for example, if a topic has nine messages and a group ID identifies three consumer instances, each instance will consume nine messages.
    // Set the broadcast subscription mode
    properties.put(PropertyKeyConst.MessageModel, PropertyValueConst.BROADCASTING);
    Note
    You need to ensure that all consumer instances under the same group ID have the same subscription relationships.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support