RichardKnop / machinery

Machinery is an asynchronous task queue/job queue based on distributed message passing.
Mozilla Public License 2.0
7.52k stars 914 forks source link

Receiving message will not be processed until visibility timeout when worker starts to quit #785

Open tomo25 opened 1 year ago

tomo25 commented 1 year ago

Hi, I'm using v1 and sqs as a broker.

When the message receipt is in progress and worker starts to shutdown, the worker will wait for the message to be received from the broker but will not process it and the task will end up not to be executed until visibility timeout.

Worker should wait until the receiving message is finished processing, and then shutdown gracefully.

The main reason why this is happening is that the worker stops to consume new task by closing b.stopChan before all the message is finished receiving. https://github.com/RichardKnop/machinery/blob/master/v1/common/broker.go#L117

Closing deliveries before the task process is finished will also make the receiving message not able to be processed. https://github.com/RichardKnop/machinery/blob/master/v1/brokers/sqs/sqs.go#L86

tomo25 commented 1 year ago

here is an implementation for sqs. https://github.com/tomo25/machinery/pull/1

it's working for me so far.