Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
Yandex Serverless Containers
  • Comparison with other Yandex Cloud services
    • Overview
    • Container
    • Invoking a container
    • Runtime environment
    • Networking
    • Mounting external resources to a container file system
    • Long-lived containers
    • Container termination notifications
      • Overview
      • Timer
      • Trigger for Message Queue
      • Trigger for Object Storage
      • Trigger for Container Registry
      • Trigger for Yandex 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
  • Access management
  • Pricing policy
  • Terraform reference
  • Audit Trails events
  • Release notes
  • FAQ

In this article:

  • Roles required for the proper operation of a trigger for Message Queue
  • Message Queue trigger message format
  • See also
  1. Concepts
  2. Trigger
  3. Trigger for Message Queue

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

Written by
Yandex Cloud
Updated at August 22, 2024
  • Roles required for the proper operation of a trigger for Message Queue
  • Message Queue trigger message format
  • See also

The trigger for Message Queue takes the load off the message queue. It picks up messages from the queue and passes them to a Serverless Containers container for processing. Once the messages are successfully processed, the trigger deletes them from the queue, and if an error occurs, it places the 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 retention period expires.

Warning

  • You can only create a trigger for a standard message queue.
  • The trigger must be in the same cloud as the queue from which it reads messages.
  • Only one trigger can be created for each message queue.

When the trigger is running, requests to the message queue are free of charge.

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

For more information about creating a trigger for Message Queue, see Creating a trigger for Message Queue that sends messages to a Serverless Containers container.

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

  • To create a trigger, you need:
    • viewer role for a folder with a message queue the trigger reads messages from.
    • viewer role for the folder with the container that the trigger invokes.
    • Permission for the service account under which the trigger executes the operations. This permission comes with the iam.serviceAccounts.user and editor roles or higher.
  • For the trigger to fire, service accounts need the following roles:
    • editor for 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.

Message Queue trigger message formatMessage Queue trigger message format

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

{
   "messages":[
      {
         "event_metadata":{
            "event_id":"cce76685-5828-4304-a83d-9564********",
            "event_type":"yandex.cloud.events.messagequeue.QueueMessage",
            "created_at":"2019-09-24T00:54:28.980441Z",
            "cloud_id":"b1gvlrnlh2sd********",
            "folder_id":"b1g88tflh2sd********",         
         },
         "details":{
            "queue_id":"yrn:yc:ymq:ru-central1:21i6v06sqmsa********:event-queue",
            "message":{
               "message_id":"cce76685-5828-4304-a83d-9564********",
               "md5_of_body":"d29343907090dff4cec4a9a0********",
               "body":"message body",
               "attributes":{
                  "SentTimestamp":"1569285804456"
               },
               "message_attributes":{
                  "messageAttributeKey":{
                     "data_type":"StringValue",
                     "string_value":"value"
                  }
               },
               "md5_of_message_attributes":"83eb2d0afefb150c1ffe69f6********"
            }
         }
      },
      {
         "event_metadata":{
            "event_id":"1f32fd25-11fc-4c08-88e7-d871********",
            "event_type":"yandex.cloud.events.messagequeue.QueueMessage",
            "created_at":"2019-09-24T00:54:28.980492Z",
            "cloud_id":"b1gvlrnlh2sd********",
            "folder_id":"b1g88tflh2sd********",
         },
         "details":{
            "queue_id":"yrn:yc:ymq:ru-central1:21i6v06sqmsa********:event-queue",
            "message":{
               "message_id":"1f32fd25-11fc-4c08-88e7-d871********",
               "md5_of_body":"d29343907090dff4cec4a9a0********",
               "body":"message body",
               "attributes":{
                  "SentTimestamp":"1569285806456"
               },
               "message_attributes":{
                  "messageAttributeKey":{
                     "data_type":"StringValue",
                     "string_value":"value"
                  }
               },
               "md5_of_message_attributes":"83eb2d0afefb150c1ffe69f6********"
            }
         }
      }
   ]
}

See alsoSee also

  • Trigger for Message Queue that sends messages to a Cloud Functions function
  • Trigger for Message Queue that sends messages to WebSocket connections

Was the article helpful?

Previous
Timer
Next
Trigger for Object Storage
Yandex project
© 2025 Yandex.Cloud LLC