Message Queue

Last Updated on : 2023-03-07 03:15:08download

Tuya provides the message queue service to help you subscribe to and forward instant messages as required. For example, subscribe to real-time device logs that can be locally stored, or link log storage with other systems.

How it works

Message queue is used to proactively push the event data through Pulsar to meet the demands for real-time and persistent messages.

Pulsar is a multi-tenant, high-performance solution for server-to-server messaging. Pulsar was originally developed by Yahoo and now is under the stewardship of the Apache Software Foundation. Tuya modifies and customizes the message queue technology based on open-source Pulsar.

As a message broker, the message queue is built on the Pub/Sub pattern. In this design mode:

  • Publish: Producers publish messages to topics. Consumers subscribe to those topics, process incoming messages, and send an acknowledgment when processing is completed. The message queue allocates multiple partitions for each topic and sends messages to consumers according to partitions.

  • Subscribe: When a subscription is created, the message queue retains all the matched messages. Retained messages are discarded only when a consumer acknowledges that those messages are processed successfully. Moreover, multiple consumers can subscribe to the same topic. At the end of message consumption, consumers need to send acknowledgments to the message queue, so the message queue can discard these messages.

Message process

  • Message development process:

    Message Queue

  • Message receiving process:

    Message Queue


  • Authentication security:

    The message queue system adopts a highly optimized authentication algorithm and dynamic tokens to enhance security. You can ignore the implementation details and accomplish the authentication based on the SDK provided by cloud development.

  • Data security:

    • Transmission security: Transmit data over the SSL protocol.
    • Business security: Business data is encrypted with the AES-128 algorithm and all the requests are signed.