AWS SQS FIFO 队列事件源,是否支持 maximumBatchingWindowInSeconds?

时间:2021-03-26 00:50:36

标签: amazon-web-services aws-lambda amazon-sqs aws-cdk

文档说现在支持 maximumBatchingWindowInSeconds 并且:

<块引用>

对于 FIFO 队列,最大值为 10。对于超过 10 的批处理大小,您还必须将 MaximumBatchingWindowInSeconds 参数设置为至少 1 秒。

但是,我在尝试创建事件源映射时收到:“提供的请求无效:FIFO 队列不支持批处理窗口”。

那么它是否受支持,如果是,我该如何启用它?

我需要一个批量大于 10 的 FIFO 队列。

我正在使用 AWS CDK 创建资源堆栈。我的 EventSourceMapping 看起来像这样:

const cfnEventSourceMapping = new CfnEventSourceMapping(this, 'Auth0ImportQEventSourceMapping', {
  batchSize: 10,
  enabled: true,
  eventSourceArn: auth0ImportQ.queueArn,
  functionName: auth0ImportLambda.functionName,
  maximumBatchingWindowInSeconds: 10,
});

3 个答案:

答案 0 :(得分:0)

措辞有点混乱,但 MaximumBatchingWindowInSeconds 与 FIFO 队列不兼容。

FIFO 最大批量大小为 10,引用 MaximumBatchingWindowInSeconds 设置的句子谈到了不适用于 FIFO 队列的批量大小 >10。

只需删除 MaximumBatchingWindowInSeconds 就可以了。

答案 1 :(得分:0)

MaximumBatchingWindowInSeconds 仅适用于标准队列(非 FIFO):

<块引用>

(流和SQS 标准队列)在调用函数之前收集记录的最长时间,以秒为单位。默认值为零。

所以不要设置这个参数。此外,您还需要确保您的 fifo 队列的 Default visibility timeout 更大然后是 lambda 超时。

答案 2 :(得分:0)

AWS 文档 https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html 明确指出参数 MaximumBatchingWindowInSeconds 只能用于标准队列。而且 FIFO 不是标准的队列。

Batch window – Specify the maximum amount of time to gather records before invoking the function, in seconds. Only applicable to standard queues.