SQS Consumer 停止后继续轮询

问题描述 投票:0回答:0

我有一个 Node 应用程序,一旦 SIGTERM 信号被云 orcherstator 发送,它就会观察到它。 作为第一步,我关闭了 SQS 消费者,然后等待所有任务运行完成,但即使我关闭了消费者,它在关闭操作后仍然继续处理消息。

    if (consumer != null) { // sanity check
      logger.log("Stopping SQS consumer...");
      try {
        consumer.stop();
        logger.log("SQS consumer stopped.");
      } catch (error: any) {
        logger.warn(`Error stopping SQS consumer during shutdown, this ain't good. error=${error}`);
      }
    }
{"name":"Index","hostname":"blah","pid":1,"level":"info","msg":"SQS consumer stopped.","time":"2023-03-21T22:58:13.418Z","v":0,"timestamp":"1679439493418"}

{"name":"Index","hostname":"blah","pid":1,"level":"info","msg":"Message received:  ...", "time":"2023-03-21T22:58:14.872Z","v":0,"timestamp":"1679439494872"}

这些消息之间的时间差为 1.5 秒。

如何解释这种行为?

"sqs-consumer": "5.6.0"

https://github.com/bbc/sqs-consumer/

为此挠头。

node.js amazon-sqs
© www.soinside.com 2019 - 2024. All rights reserved.