sqs所有消息都进入死信队列

b4lqfgs4  于 2021-07-03  发布在  Java
关注(0)|答案(1)|浏览(566)

我已经使用terraform配置了一个sqs队列和一个额外的死信队列。

resource "aws_sqs_queue" "sqs_deadletter" {
  name = "worker-dead-letter"
}

resource "aws_sqs_queue" "sqs" {
  name = "worker"
/* TODO: If I enable this all messages goes to the dead letter queue
  redrive_policy = jsonencode({
    deadLetterTargetArn = aws_sqs_queue.sqs_deadletter.arn
    maxReceiveCount = 4
  })

* /

}

resource "aws_lambda_event_source_mapping" "sqs" {
  event_source_arn = aws_sqs_queue.sqs.arn
  function_name = aws_lambda_function.worker.arn
  enabled = true
  batch_size = var.batch_size
}

我使用下面的处理程序来处理我的消息。

@Introspected
class LegacyToModernRequestHandler : MicronautRequestHandler<SQSEvent, Unit>() {
    private val logger = KotlinLogging.logger {}

    override fun execute(input: SQSEvent) {
        input.records.forEach {
            handle(it)
        }
    }

    private fun handle(message: SQSMessage) {
        val key = message.body
        logger.info { "LegacyToModernRequestHandler($key)" }
    }
}

但我所有的信息都会传到dlq。我怎样才能表明处理成功,这样就不会发生这种情况?

vs3odd8k

vs3odd8k1#

如果不使用自动确认模式,则必须显式确认消息,以便成功处理该消息。否则将转到dlq。您能展示一下您是如何配置sqs队列的吗?

相关问题