From bb61e95c17a089805fc3041bea822b3b86730951 Mon Sep 17 00:00:00 2001 From: Piotr Biernat Date: Wed, 30 Sep 2020 22:13:46 +0200 Subject: [PATCH] [fix] Manually mark queue as done after task finishes. Now we dont lose task, even if worker crash. --- queue/consumer/test_worker.go | 1 + queue/rabbitmq.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/queue/consumer/test_worker.go b/queue/consumer/test_worker.go index 989caad..f9823dd 100644 --- a/queue/consumer/test_worker.go +++ b/queue/consumer/test_worker.go @@ -20,4 +20,5 @@ func callback(d amqp.Delivery) { log.Println("Received message: ", string(d.Body)) time.Sleep(5 * time.Second) log.Println("Finished!") + d.Ack(false) } diff --git a/queue/rabbitmq.go b/queue/rabbitmq.go index 1450cec..07de4db 100644 --- a/queue/rabbitmq.go +++ b/queue/rabbitmq.go @@ -84,7 +84,7 @@ func (a *AMQP) Consume(queueName string, callback func(d amqp.Delivery)) { msgs, a.err = a.chn.Consume( queueName, // queue "", // consumer - true, // auto-ack + false, // auto-ack false, // exclusive false, // no-local false, // no-wait