Each consumer group serves as the identity of a message consumer. IoT Platform can forward messages to a specified consumer group. After a message consumer joins the consumer group, the message consumer can connect to IoT Platform and receive messages.

Background information

  • Purpose: Your cloud application can obtain forwarded messages by listening to consumer groups. The following methods are available:
    • Configure an AMQP server-side subscription: You can use an AMQP server-side subscription to subscribe to a specified type of messages that are sent by all the devices of a product. This subscription also allows you to forward these messages to a specified consumer group.
    • Configure a data forwarding rule: You can use the data forwarding feature to forward messages from a specified topic to an AMQP consumer group.

    For more information about the differences between server-side subscriptions and data forwarding, see Compare data forwarding solutions.

  • Usage: You can specify a consumer group ID for an AMQP client. Then, the AMQP client can connect to IoT Platform and receive messages. For more information, see Connect an AMQP client to IoT Platform.

    A consumer group consists of multiple AMQP clients. These clients share the ID of the consumer group. After a device message is sent to IoT Platform, IoT Platform forwards the message to a random client in the consumer group. A consumer group can have a maximum of 64 clients.

Create a consumer group

  1. Log on to the IoT Platform console.
  2. In the left-side navigation pane, choose Rules > Server-side Subscription and click the Consumer Groups tab.
  3. Click Create Consumer Group.
  4. In the Create Consumer Group dialog box, enter a group name and click OK.
    The consumer group name must be 4 to 30 characters in length, and can contain letters, digits, and underscores (_).

View and monitor consumer groups

You can view the message consumption rate and the number of accumulated messages of a consumer group. To monitor consumer groups, you can also configure an alert rule in CloudMonitor.

  1. On the Consumer Groups tab, find the required consumer group and click View.
  2. On the Consumer Group Status tab, you can view the Real-time Message Consumption Rate, Accumulated Message Consumption Rate, Accumulated Messages, and Last Consumed At parameters. You can also view online clients.
    If the number of accumulated messages is greater than 0, click Clear that appears on the right side of Accumulated Messages to clear these messages.
  3. Configure an alert rule in CloudMonitor. You can use the alert rule to monitor the number of accumulated messages and the message consumption rate. You can receive alert notifications.
    1. On the Consumer Group Status tab, click Alert Settings.
    2. On the Create Alert Rule page, set the required parameters and click Confirm.
      Section Parameter Description
      Related Resource Product Select IoT Platform.
      Resource Range Valid values:
      • All Resources: specifies all the consumer groups that are owned by each instance.
      • Instance: specifies a consumer group.
      Region This parameter is available if you set the Resource Range parameter to Instance.

      Select an IoT Platform instance to be monitored, the region where the instance resides, and a consumption group. You can select multiple consumer groups.

      If the number of accumulated messages or the consumption rate of a consumer group reaches the specified threshold, an alert notification is sent.

      Instance
      Consumer Group
      Set Alert Rules Alert Rule The name of the alert rule.
      Rule Description The conditions that are used to trigger alerts. You can configure the following items:
      • A metric to be monitored.
      • A scan period. For example, if the scan period is set to 60 minutes, scans are performed every 60 minutes.
      • An alert condition. For example, if the value of a specified metric is greater than 1,000 for three consecutive scan periods, an alert is triggered.

      You can click Add Alert Rule under Rule Description to configure multiple alert rules.

      Mute for Set a retry interval. If an alert persists, CloudMonitor sends another alert notification after the specified retry interval.
      Effective Period Set the validity period of the alert rule. The alert rule sends alert notifications only within the specified validity period.
      Notification Method Notification Contact Set the required contact groups that are used to receive alert notifications. For more information, see Configure alert contacts.
      Notification Methods

      Email + DingTalk (Info) You can set the parameter only to this value.

      Auto Scaling Specify whether to use Auto Scaling. If you select this check box, the specified scaling rule is triggered when an alert is generated.
      Log Service Specify whether to use Log Service. If you select this check box, the alert message is written to Log Service when an alert is generated.
      Email Subject This parameter is available if you set the Resource Range parameter to Instance. Enter the subject of an email that is sent to the specified alert contacts if an alert occurs. By default, an email subject includes a product name, metric name, and instance ID.
      Email Remark Enter the remarks of an email that is sent to the specified alert contacts if an alert occurs.
      HTTP Callback Enter a URL that is accessible over the Internet. CloudMonitor pushes alert notifications to this URL by using HTTP POST requests.

Delete a consumer group

You can delete a consumer group. However, you cannot delete the default consumer group. After a consumer group is deleted, all clients in the group stop receiving messages.

  1. Disassociate a subscription. If a consumer group is associated with a subscription, you must disassociate the subscription from the consumer group. If the consumer group has no subscriptions, you can skip this step.
    1. On the Consumer Groups tab, click View next to the consumer group.
    2. On the Subscribed Products tab of the Consumer Group Details page, find the required product and click Unsubscribe next to the product. In the dialog box that appears, accept the agreement and click Confirm.
      Note If only one consumer group is associated with the server-side subscription of the product, the unsubscribe action is unavailable on the Consumer Group Details page. In this case, go to the Server-side Subscription page, edit the subscription, and change the consumer group or delete the subscription.
  2. On the Consumer Groups tab of the Server-side Subscription page, find the required consumer group and click Delete. In the dialog box that appears, accept the agreement and click Confirm.

References

For more information about how to specify a consumer group ID for an AMQP client and use the AMQP client to receive messages, see the following topics:

Related operations

Operation Description
CreateConsumerGroup Creates a consumer group that is required for an AMQP server-side subscription.
UpdateConsumerGroup Modifies the name of a consumer group.
QueryConsumerGroupByGroupId Queries the details of a consumer group by consumer group ID.
QueryConsumerGroupList Queries all the consumer groups of an account, or performs a fuzzy search by consumer group name.
QueryConsumerGroupStatus Queries the status of a consumer group when an AMQP server-side subscription is enabled. The status information includes the online client information, message consumption rate, number of accumulated messages, and latest message consumption time.
ResetConsumerGroupPosition Clears the accumulated messages of a consumer group when an AMQP server-side subscription is enabled.
DeleteConsumerGroup Deletes a consumer group.