Add missing recall implementation (#375)

* Add missing recall implementation
* create DeferredRecall if it doesn't exist

Co-authored-by: Bas van Berckel <bas.vanberckel@copernica.com>
This commit is contained in:
Bas van Berckel 2020-10-21 15:21:28 +02:00 committed by GitHub
parent cb4bcacc2f
commit 110706771a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 0 deletions

View File

@ -589,6 +589,24 @@ DeferredConsumer& ChannelImpl::consume(const std::string &queue, const std::stri
return *deferred;
}
/**
* Tell that you are prepared to recall/take back messages that could not be
* published. This is only meaningful if you pass the 'immediate' or 'mandatory'
* flag to publish() operations.
*
* THis function returns a deferred handler more or less similar to the object
* return by the consume() method and that can be used to install callbacks that
* handle the recalled messages.
*/
DeferredRecall &ChannelImpl::recall()
{
// create the DeferredRecall if it does not exist
if (!_recall) _recall = std::make_shared<DeferredRecall>(this);
// return the deferred handler
return *_recall;
}
/**
* Cancel a running consumer
* @param tag the consumer tag