Simple Message Queue (SMQ, formerly MNS) integrates with Function Compute (FC) to build event-driven architectures. SMQ queues and topics act as event sources that automatically trigger functions when messages arrive, and FC can route function execution results back to SMQ queues or topics for downstream processing.
How it works
SMQ and FC connect in two directions:
| Direction | Description |
|---|---|
| SMQ triggers FC | A message arrives in a queue or topic, SMQ evaluates your trigger rules, and invokes the associated function. |
| FC outputs to SMQ | SMQ sends data generated during function processing or result data to its own queues or topics through asynchronous invocation destinations. |
Trigger functions from SMQ messages
SMQ queues and topics serve as event sources for FC. When a message arrives and matches the trigger rules you defined, SMQ automatically invokes the associated function.
SMQ supports two trigger types:
| Trigger type | Event source | Setup instructions |
|---|---|---|
| Queue trigger | Messages sent to a queue | SMQ queue triggers |
| Topic trigger | Messages published to a topic | SMQ topic triggers |
Route function results to SMQ
SMQ sends data generated during function processing or result data to its own queues or topics through asynchronous invocation destinations.
To configure this:
Open the Function Compute console.
Configure asynchronous invocation for your function and set SMQ as the destination service.
For step-by-step instructions, see Configure the destination service for asynchronous invocations.
Sample code
These Node.js examples demonstrate sending messages from a function to SMQ: