I've configured an SQS queue and an additional dead letter queue using terraform.
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
}
I use the below handler to process my messages.
@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)" }
}
}
But all my messages goes to the DLQ. How can I indicate successful handling so that doesn't happen?