Manage AMQP consumer groups

更新时间:
复制 MD 格式

A consumer group is an identifier for a group of message consumers. Multiple consumers can form a consumer group to connect to IoT Platform. After you set up an Advanced Message Queuing Protocol (AMQP) server-side subscription, IoT Platform forwards messages received from devices to the corresponding consumer group. Each message that is forwarded to the consumer group is received by only one of the consumers in that group. This topic describes how to create, view, and delete consumer groups in IoT Platform.

How it works

image

An AMQP server-side subscription forwards messages of a specified type from all devices under a product to one or more consumer groups. A random consumer in each group receives the message. Consumer groups are identified by their group IDs. Each AMQP client can be configured with only one consumer group ID. Each consumer group can contain up to 64 AMQP clients. You must first create a consumer group, then configure the consumer group ID on the AMQP client, and finally configure an AMQP server-side subscription.

  • Subscription relationship 1: Forwards messages from Product 1 to Consumer group 1 and Consumer group 2.

  • Subscription relationship 2: Forwards messages from Product 2 to Consumer group 2.

An AMQP server-side subscription can forward messages of a specified type only from all devices under a single product. For more flexible message forwarding, such as forwarding messages from specific devices to an AMQP client, you can use the data forwarding feature of IoT Platform. First, you must specify that device topic messages are forwarded to a consumer group for an AMQP server-side subscription. The messages are then forwarded to the AMQP client that consumes messages from that consumer group. For more information, see Data forwarding.

Create a consumer group

  1. Log on to the IoT Platform console.

  2. On the Overview page, find the instance that you want to manage and click the instance ID or instance name.

  3. In the navigation pane on the left, choose Message Forwarding > Server-side Subscription, and then click the Consumer Groups tab.

  4. Click Create Consumer Group.

  5. 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, underscores (_), and Chinese and Japanese characters. Each Chinese or Japanese character counts as two characters.

View and monitor consumer groups

You can view the message consumption rate and the number of stacked messages in a consumer group. You can also set alert rules in Cloud Monitor to monitor the consumer group.

  1. In the Consumer Groups list, find the consumer group that you want to view and click View.

  2. On the Consumer Group Status tab, view the Real-time Message Consumption Rate, Accumulated Message Consumption Rate, Accumulated Messages, Latest Consumption Time, and the list of online clients.

    If the Accumulated Messages count is 1 or greater, the Purge button appears. You can click the button to clear the stacked messages.

    Note

    After you create a message group:

    • If a consumer group has never been online, it is in an offline state and messages sent to the consumer group are not stacked.

    • If a consumer group was online and then goes offline, it is in an offline state and messages sent to the consumer group are stacked.

    消费组状态

  3. On the Consumer Group Status tab, click Alert Settings. On the Create Alert Rule page, you can configure a threshold-based alert rule in Cloud Monitor to monitor the number of stacked messages and the consumption rate of the consumer group and to receive alert notifications.

    Set Product to IoT Platform-Server-side Subscription and configure other parameters as needed. For more information, see Create a threshold-based alert rule.

  4. On the Consumer Group Details page, click the Consumption Logs tab to view specific consumption records.

Delete a consumer group

Warning

After you delete a consumer group, all consumers in the group stop receiving messages. The associated server-side subscription service becomes unavailable, which may interrupt your business. Proceed with caution.

You can delete consumer groups that you create. You cannot delete the default consumer group of IoT Platform.

  1. If the consumer group is associated with a subscription relationship, you must first unsubscribe it. If the consumer group has no subscription relationships, you can skip this step.

    1. In the Consumer Groups list, find the consumer group and click View.

    2. On the Consumer Group Details page, on the Subscribed Products tab, find the product and click Unsubscribe, and then click OK.

      Note

      If only one consumer group is associated with the server-side subscription for the product, you cannot unsubscribe on the Consumer Group Details page. You must return to the Server-side Subscription page and click the Subscriptions tab to edit or delete the subscription.

  2. On the Server-side Subscription page, on the Consumer Groups tab, find the consumer group and click Delete, and then click OK.

References

To configure a consumer group ID on an AMQP client to receive messages, see the following topics:

Related API operations

API

Description

CreateConsumerGroup

Creates a consumer group to use for an AMQP server-side subscription.

UpdateConsumerGroup

Modifies the name of a consumer group.

QueryConsumerGroupByGroupId

Queries the details of a consumer group by its ID.

QueryConsumerGroupList

Queries a list of all consumer groups for your account, or performs a fuzzy search by consumer group name.

QueryConsumerGroupStatus

When you use an AMQP server-side subscription, queries the status of a consumer group. The status includes online client information, message consumption rate, number of stacked messages, and the latest consumption time.

ResetConsumerGroupPosition

When you use an AMQP server-side subscription, purges the stacked messages of a consumer group.

DeleteConsumerGroup

Deletes a consumer group.