Message Gateway

Last Updated on : 2023-05-22 06:38:10download

Message gateway allows you to subscribe to and forward various instant messages. For example, subscribe to real-time device logs for local storage, or link with other systems.

Working principle

Message gateway is used to proactively push the event data through Pulsar, so as to meet the demands for real-time, 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. Currently, Tuya message gateway is customized and modified based on open source Pulsar.

As a message broker, the message gateway 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 gateway allocates multiple partitions for each topic and sends messages to consumers according to partitions.

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

Message process

  • Message development process:
    Message Gateway
  • Message receiving process:
    Message Gateway

Security

  • Authentication security:

    The message gateway 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 Tuya Cube.

  • 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.