SMQ messaging configuration example for asynchronous tasks

Updated at: 2024-12-26 03:11

This topic describes how to obtain execution status information of asynchronous tasks in Intelligent Media Management (IMM) by using Simple Message Queue (SMQ).

Create SMQ resources

Step 1: Create an SMQ topic

  1. Log on to the SMQ console.

  2. In the left-side navigation pane, click Topics. On the page that appears, click Create Topic.

  3. In the Create Topic panel, configure the parameters. In this example, a topic named tf-test-mns-topic is created.

    image

  4. Click OK.

Step 2: Create an SMQ queue

  1. Log on to the SMQ console.

  2. In the left-side navigation pane, click Queues. On the page that appears, click Create Queue.

  3. In the Create Queue panel, configure the parameters. In this example, a queue named tf-test-mns-queue is created.

    image

  4. Click OK.

Step 3: Subscribe the queue to the topic

  1. Log on to the SMQ console.

  2. In the left-side navigation pane, click Topics. On the page that appears, click the name of the topic created in Step 1: Create an SMQ topic (tf-test-mns-topic in this example).

    image

  3. On the Topic Details page, click Subscriptions. On the page that appears, click Create Subscription.

  4. In the Create Subscription panel, configure the parameters. In this example, a subscription named tf-test-mns-subscription is created.

    image

    • Subscription: the type of the subscription. Select Queue.

    • Receiver Endpoint: Select the tf-test-mns-queue queue that you created in Step 2: Create an SMQ queue.

    • Message Format: the message format. Select JSON.

  5. Click OK.

(Optional) Create OSS resources

Note

If you have available Object Storage Service (OSS) resources, you can skip to the next step to initiate a request to IMM.

Step 1: Create a bucket

  1. Log on to the OSS console.

  2. In the left-side navigation pane, click Buckets. On the Buckets page, click Create Bucket.

  3. In the Create Bucket panel, create a bucket. In this example, a bucket named tf-test-oss-bucket is created.

Step 2: Upload a file

  1. Log on to the OSS console.

  2. In the left-side navigation pane, click Buckets. On the Buckets page, click the tf-test-oss-bucket bucket that you created in Step 1: Create a bucket.

  3. On the Objects page, lick Upload Object to upload a file. In this example, a file named 1.docx is uploaded.

Initiate a request to IMM

Step 1: Create a project

  1. Log on to the IMM console.

  2. In the left-side navigation pane, click Project List. On the page that appears, click Create Project.

  3. In the Create Project panel, specify a project name and a service-linked role. In this example, the project name is tf-test-imm-project and the service-linked role is the default role AliyunIMMDefaultRole.

    Important

    You can specify a custom service-linked role. For information about how to grant permissions to a role, see Configure a service role for a project.

    image

  4. Click OK.

Step 2: Initiate a request to IMM

  1. Log on to OpenAPI Explorer.

  2. In the API navigation tree, choose Document Processing > CreateOfficeConversionTask.

  3. Configure the parameters.

    image

    image

    • ProjectName: Specify the project that you created in Step 1: Create a project. In this example, the project is tf-test-imm-project.

    • SourceURI: Specify the path to the object uploaded in Step 2: Upload a file or the path to another document object in the bucket. In this example, the source path is oss://tf-test-oss-bucket/1.docx.

    • TargetURIPrefix: Specify the OSS path to which you want to store the output object. In this example, the path is oss://tf-test-oss-bucket/output.

    • TargetType: Specify the type of the output object. In this example, the type is png.

    • TopicName: Enter the SMQ topic that you created in Step 1: Create an SMQ topic. In this example, the topic is tf-test-mns-topic.

  4. Click Initiate Call.

Receive SMQ messages

  1. Log on to the SMQ console.

  2. In the left-side navigation pane, click Queues. On the Queues page, click the name of the queue that you created in Step 2: Create an SMQ queue. In this example, the queue is tf-test-mns-queue.

    image

  3. In the upper-right corner of the Queue Details page, click Send Messages.

    image

  4. On the Send Messages page, click Receive Message. The message is received and appears in the message list.

    image

  5. Locate the message in the message list and click Details in the Actions column.

    1111111

FAQ

How do I fix a failure in receiving SMQ messages?

If you fail to receive SMQ messages, perform the following checks:

  • Check whether the SMQ topic and IMM project reside in the same region.

  • Check whether the SMQ queue is subscribed to the topic and whether the Message Format parameter is set to JSON for the subscription.

  • Check whether multiple consumers are in the queue at the same time.

  • Check whether the role specified for the IMM project has the permission to send data to SMQ. For more information about role permissions, see Configure a service role for a project.

  • On this page (1, T)
  • Create SMQ resources
  • Step 1: Create an SMQ topic
  • Step 2: Create an SMQ queue
  • Step 3: Subscribe the queue to the topic
  • (Optional) Create OSS resources
  • Step 1: Create a bucket
  • Step 2: Upload a file
  • Initiate a request to IMM
  • Step 1: Create a project
  • Step 2: Initiate a request to IMM
  • Receive SMQ messages
  • FAQ
  • How do I fix a failure in receiving SMQ messages?
Feedback
phone Contact Us

Chat now with Alibaba Cloud Customer Service to assist you in finding the right products and services to meet your needs.

alicare alicarealicarealicare