AWS Step Functions
AWS 文档中描述的 AWS 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 AWS 服务入门

使用 Step Functions 调用 Amazon SQS

Step Functions can control certain AWS services directly from the Amazon 状态语言. For more information, see:

支持的 API:


There is a limit on the maximum input or result data size for a task in Step Functions. This limits you to 32,768 characters of data when you send to, or receive data from, another service. See 与状态机执行相关的限制.

下面是一个发送 Amazon SQS 消息的 Task 状态。

{ "StartAt": "Send to SQS", "States": { "Send to SQS": { "Type": "Task", "Resource": "arn:aws-cn:states:::sqs:sendMessage", "Parameters": { "QueueUrl": "", "MessageBody.$": "$.input.message", "MessageAttributes": { "my attribute no 1": { "DataType": "String", "StringValue": "attribute1" }, "my attribute no 2": { "DataType": "String", "StringValue": "attribute2" } } }, "End": true } } }

下面包含一个发布到 Amazon SQS 队列,然后等待返回任务令牌的 Task 状态。请参阅 等待具有任务令牌的回调

{ "StartAt":"Send message to SQS", "States":{ "Send message to SQS":{ "Type":"Task", "Resource":"arn:aws:states:::sqs:sendMessage.waitForTaskToken", "Parameters":{ "QueueUrl":"", "MessageBody":{ "Input.$":"$", "TaskToken.$":"$$.Task.Token" } }, "End":true } } }

要了解有关在 Amazon SQS 中接收消息的更多信息,请参阅 Amazon Simple Queue Service 开发人员指南 中的接收和删除消息

For information on how to configure IAM when using Step Functions with other AWS services, see 集成服务的 IAM 策略.