All Products
Search
Document Center

Simple Message Queue (formerly MNS):Function Compute

Last Updated:Dec 04, 2025

Simple Message Queue (SMQ, formerly MNS) can be configured to push topic messages directly to Function Compute. This topic walks you through the required steps.

Prerequisites

You have created a function in Function Compute to receive messages. For more information, see Create a function.

Step 1: Create a topic

  1. Log on to the SMQ console.

  2. In the left-side navigation pane, choose Topic Model > Topics.

  3. In the top navigation bar, select a region.

  4. On the Topics page, click Create Topic.

  5. In the Create Topic panel, set the following parameters, and then click OK.

    • Name: the name of the topic.

    • Maximum Message Length: the maximum length of the message that is sent to the topic.

    • Enable Logging Feature: specifies whether to enable the logging feature. If this feature is enabled, SMQ automatically pushes the operation logs of this topic to the specified Logstore. You can then view the message trace, delay, and other information from the logs. For more information, see Log management.

    The Topic Details page of the topic appears.

Step 2: Create a subscription

Inter-account

  1. In the left-side navigation pane of the console, choose Topic Model > Subscriptions.

  2. On the Subscriptions page, click Create Subscription.

  3. In the Create Subscription panel, configure the following parameters and click OK.

    • Topic Name: the name of the topic to which the subscription belongs.

    • Subscription Name: Enter a subscription name.

    • Subscription: Select Function Compute (FC).

    • Cross-Account: Select Inter-account.

    • Receiver Endpoint: Select the target function from the drop-down list.

    • Service-linked Role: SMQ uses the service-linked role AliyunMNSNotificationRole to trigger the function. Upon first-time use, click Create SLR {role}.

      Note
      • You only need to create the service-linked role once.

      • Avoid deleting the created role, as this will prevent SMQ from pushing messages to Function Compute.

    • (Optional) Message Filtering Tag: Enter a tag to filter messages.

    • Retry Policy: Select a retry policy.

      • BACKOFF_RETRY: retry 3 times with a random interval between 10 and 20 seconds.

      • DECAY_RETRY: retry 176 times over a total period of 1 day, with intervals in seconds as follows: 2^0, 2^1, ..., 512, 512, ..., 512.

    • Message Format: Select a message push format.

Cross-account

  1. In the left-side navigation pane of the console, choose Topic Model > Subscriptions.

  2. On the Subscriptions page, click Create Subscription.

  3. In the Create Subscription panel, configure the following parameters and click OK.

    • Topic Name: the name of the topic to which the subscription belongs.

    • Subscription Name: Enter a subscription name.

    • Subscription: Select Function Compute (FC).

    • Cross-Account: Select Cross-Account.

    • Receiver Endpoint: Enter the Alibaba Cloud Resource Name (ARN) of the target function (format: acs:fc:cn-hangzhou:${accountId}:functions/${functionName}). For information about how to obtain the function ARN, see Obtain the ARN of a function.

    • Service-linked Role: Enter the ARN of the RAM role for cross-account authorization. For information about how to obtain the RAM role ARN, see Cross-account push authorization.

    • (Optional) Message Filtering Tag: Enter a tag to filter messages.

    • Retry Policy: Select a retry policy.

      • BACKOFF_RETRY: retry 3 times with a random interval between 10 and 20 seconds.

      • DECAY_RETRY: retry 176 times over a total period of 1 day, with intervals in seconds as follows: 2^0, 2^1, ..., 512, 512, ..., 512.

    • Message Format: Select a message push format.

Step 3: Publish a message

  1. On the Topics page, find the target topic and click Publish Message from the kebab menu in the Actions column.

  2. On the page that appears, configure the following parameters and click Publish Message.

    • Message Content: Enter the message content.

    • (Optional) Message Tag: Enter a tag to filter messages.

    • Subscription Type: Select Function Compute (FC).