corvus-ch / rabbitmq-cli-consumer

Consume RabbitMQ messages into any cli program
MIT License
236 stars 36 forks source link

Graceful Shutdown #19

Closed checkphi closed 6 years ago

checkphi commented 6 years ago

I think it would be nice to have the possibility to request a graceful shutdown of the consumer, maybe utilising the SIGTERM signal.

There are situations where I want the cli-consumer to finish his current operation but don't start a new one. From what I could see right now the current process is aborted as well.

Unfortunately, I'm not capable of implementing this by myself, but I would love to see this feature.

tutNichts commented 6 years ago

Great idea! Would also be very happy to see this!

taxaos commented 6 years ago

Really great idea, we would also need a graceful shutdown of the consumer itself!

corvus-ch commented 6 years ago

I have started to experiment on this one. My changes have yielded a interesting change of behaviour and I am undecided if this is the correct direction.

The change I did, results in three messages processed in parallel and not one after the other as it is in the current release. The number of messages processed at a time can be controlled with the prefetch config.

So far, there was no concurrency and while this opens a nice opportunity, it might also be a step in the wrong direction.

Feedback would be highly appreciated.

corvus-ch commented 6 years ago

The signal SIGTERM will not cancel consumption of new messages. A current running executable will be finished and its message will be acknowledged. Any messages already received but not yet processed, will receive a negative acknowledge. The change was release as part of 2.2.0.