Manage Pulsar Notifications

Last Updated on : 2024-08-14 02:17:23download

Different from the business data channel topic ${clientId}/out/event, Pulsar notifications use an independent Pulsar channel, topic ${clientId}/out/notice, which is not affected by the business channel and can receive various high-priority non-business events in near real time.

For example, if a backlog alarm is triggered for the ${clientId}/out/event topic, Tuya will send an alert message to the Pulsar topic, making it easier for you to handle the event subsequently. Compared to SMS and email alerts, Pulsar notifications are more flexible.

Subscribe to Pulsar alert

  1. Log in to Tuya Developer Platform.

  2. Find your target project and click Open Project in the Operation column.

    Manage Pulsar Notifications

  3. On the Message Service tab, turn on the Enable switch.

    Manage Pulsar Notifications

  4. In the pop-up window of Configure Message Service, select Subscribe to Pulsar Alert, set the threshold and interval for backlog alerts, and click OK.

    Manage Pulsar Notifications

    The settings above enable the system to send a Pulsar alert message to you every 15 minutes when the number of messages accumulated in the topic ${clientId}/out/event is greater than 2,000 until the number does not exceed the threshold of 2,000.

Data signature

The data signature and message format are the same as those of the topic ${clientId}/out/event. For more information, see Data Signature.

Pulsar notification protocol number

Business Module Protocol Number bizCode eventType
Topic Backlog Alarm Notification 10000 HighPriorityNotice pulsar_backlog_notice

Message format

  • bizData Data Body Description

    Code Data Type Description
    eventType String Event type
    eventData JSON Backlog information
  • eventData Data Body Description

    Code Data Type Description
    dataCenter String Data center of backlog
    topic String Topic of backlog
    subscription String Name of subscriber for backlog topic
    backLogNum Integer Number of accumulated messages
  • Sample

    {
     "bizCode": "HighPriorityNotice",
     "bizData": {
         "eventData": "{\"dataCenter\":\"AY\",\"topic\":\"****/out/event\",\"subscription\":\"****-sub\",\"backLogNum\":2004}",
         "eventType": "pulsar_backlog_notice"
     },
     "ts": 1722432061033
    }
    

Subscription method

Change the topic in the SDK to ${clientId}/out/notice to receive Pulsar messages. When there is a backlog, Tuya will send messages to developers. For more information, see Best Practices.