Yandex Cloud
  • Services
  • Solutions
  • Why Yandex Cloud
  • Blog
  • Pricing
  • Documentation
  • Contact us
Get started
Language / Region
Yandex project
© 2023 Yandex.Cloud LLC
Yandex Serverless Containers
  • Comparison with other Yandex Cloud services
  • Getting started
  • Step-by-step instructions
  • Concepts
    • Overview
    • Container
    • Invoking a container
    • Networking
    • Runtime environments
    • Trigger
      • Overview
      • Timer
      • Trigger for Message Queue
      • Trigger for Object Storage
      • Trigger for Container Registry
      • Trigger for Cloud Logging
      • Trigger for Yandex IoT Core
      • Trigger for budgets
      • Trigger for Data Streams
      • Email trigger
    • Dead Letter Queue
    • Container logs
    • Backups
    • Quotas and limits
  • Practical guidelines
  • Access management
  • Pricing policy
  • Containers API reference
  • API Triggers reference
  • Questions and answers
  1. Concepts
  2. Trigger
  3. Trigger for Message Queue

Trigger for Message Queue that passes messages to the Serverless Containers container

Written by
Yandex Cloud
  • Roles required for the proper operation of a trigger for Message Queue
  • Trigger for Message Queue message format
  • See also

The trigger for Message Queue is used to process the message queue. It picks up messages from the queue and passes them to a Serverless Containers container for processing. Once successfully processed, a trigger deletes messages from the queue, and if an error occurs, it places messages back in the queue and sets a visibility timeout. If the queue does not have a Dead Letter Queue configured, a message will continue to be returned to a container until it is successfully processed or until its storage timeout expires.

You can only create a trigger for a standard message queue. The trigger must be in the same cloud as the queue that messages are read from. Only one trigger can be created for each message queue.

Triggers for Message Queue require service accounts to read messages from a message queue and invoke a container. You can use the same service account for both operations.

Roles required for the proper operation of a trigger for Message Queue

  • To create a trigger, you need:
    • The viewer role for the folder with the message queue that the trigger reads messages from.
    • The viewer role for the folder with the container that the trigger invokes.
    • Permission to the service account on whose behalf the trigger executes the operations. This permission is included in the iam.serviceAccounts.user and editor roles and higher.
  • To run a trigger, service accounts need the following roles:
    • editorfor the folder with the message queue that the trigger reads messages from.
    • serverless.containers.invoker for the folder with the container that invokes the trigger.

Read more about access management.

Trigger for Message Queue message format

After the trigger picks up a message from the queue, it passes it to the container in the following format:

{
   "messages":[
      {
         "event_metadata":{
            "event_id":"cce76685-5828-4304-a83d-95643c0507a0",
            "event_type":"yandex.cloud.events.messagequeue.QueueMessage",
            "created_at":"2019-09-24T00:54:28.980441Z"
         },
         "details":{
            "queue_id": "yrn:yc:ymq:ru-central1:21i6v06sqmsaoeon7nus:event-queue",
            "message":{
               "message_id":"cce76685-5828-4304-a83d-95643c0507a0",
               "md5_of_body":"d29343907090dff4cec4a9a0efb80d20",
               "body":"message body",
               "attributes":{
                  "SentTimestamp":"1569285804456"
               },
               "message_attributes":{
                  "messageAttributeKey":{
                     "dataType":"StringValue",
                     "stringValue":"value"
                  }
               },
               "md5_of_message_attributes":"83eb2d0afefb150c1ffe69f66c3de068"
            }
         }
      },
      {
         "event_metadata":{
            "event_id":"1f32fd25-11fc-4c08-88e7-d871d6ffb91d",
            "event_type":"yandex.cloud.events.messagequeue.QueueMessage",
            "created_at":"2019-09-24T00:54:28.980492Z"
         },
         "details":{
            "queue_id": "yrn:yc:ymq:ru-central1:21i6v06sqmsaoeon7nus:event-queue",
            "message":{
               "message_id":"1f32fd25-11fc-4c08-88e7-d871d6ffb91d",
               "md5_of_body":"d29343907090dff4cec4a9a0efb80d20",
               "body":"message body",
               "attributes":{
                  "SentTimestamp":"1569285806456"
               },
               "message_attributes":{
                  "messageAttributeKey":{
                     "dataType":"StringValue",
                     "stringValue":"value"
                  }
               },
               "md5_of_message_attributes":"83eb2d0afefb150c1ffe69f66c3de068"
            }
         }
      }
   ]
}

See also

  • Trigger for Message Queue that passes messages to the Cloud Functions function.

Was the article helpful?

Language / Region
Yandex project
© 2023 Yandex.Cloud LLC
In this article:
  • Roles required for the proper operation of a trigger for Message Queue
  • Trigger for Message Queue message format
  • See also