bloomberg / rmqcpp

A batteries included C++ RabbitMQ Client Library/API.
Apache License 2.0
68 stars 16 forks source link

Do not destroy consumer on cancellation #28

Closed mvrsss closed 11 months ago

mvrsss commented 11 months ago

Problem statement

Previously, consumer would get destroyed after cancel() call and recreated on start() on a rmqamqp::ReceiveChannel. The reasoning behind that change is that current consumer lifecycle is not complete, i.e. NOT_CONSUMING->STARTING->CONSUMING->CANCELLING->CANCELLED->X. Since we are adding resume() function, we had to store the previous state of the consumer before cancelling. To simplify this, we decided to not destroy the consumer. Also, in current design we have only single consumer per channel, so we were thinking of merging channel and consumer states.

Proposed changes

Consumer does not get destroyed after calling cancel() function, but will be in a CANCELLED state. State will be changed to NOT_CONSUMING upon channel reset.