After you integrate a Message Service (MNS) topic with a function in Function Compute by using EventBridge, the function subscribes to the topic. The MNS topic trigger can trigger the execution of the function. The functions can be used to process the messages published to the MNS topic.
MNS is a distributed messaging service that features scalability, high efficiency, reliability, security, and availability. MNS allows application developers to transfer data and notifications between the distributed components of an application and build a loosely coupled system. In MNS, messages are published to topics. A publisher can call the PublishMessage operation to publish a message to a topic, and a subscriber to the topic receives the message. For more information, see PublishMessage.
Configuring a trigger for an MNS topic is equivalent to registering a function as a subscriber to the MNS topic. When a publisher publishes a message to the MNS topic, the message is passed to the function and used as the event parameter of the function handler to trigger the function. For more information, see Basic information.
The following benefits are delivered after MNS and Function Compute are integrated:
Allows you to perform advanced processing on a message before you send the message in an email or a text message.
Allows you not to create services at HTTP endpoints.
Supports abundant custom processing. For example, you can send a message to Slack or persist a specified message.
The MNS topic must in the same region as the function in Function Compute.
You must avoid recursive invocations.
Avoid the following logic when you write code for a function: Topic A triggers Function B, and Function B publishes a new message to Topic A. This logic results in an infinite loop of function invocations.