2014-04-15 17:39:52 +08:00
|
|
|
/**
|
|
|
|
|
* DeferredConsumer.cpp
|
|
|
|
|
*
|
|
|
|
|
* Implementation file for the DeferredConsumer class
|
|
|
|
|
*
|
2017-03-08 20:32:51 +08:00
|
|
|
* @copyright 2014 - 2017 Copernica BV
|
2014-04-15 17:39:52 +08:00
|
|
|
*/
|
|
|
|
|
#include "includes.h"
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Namespace
|
|
|
|
|
*/
|
|
|
|
|
namespace AMQP {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Report success for frames that report start consumer operations
|
|
|
|
|
* @param name Consumer tag that is started
|
|
|
|
|
* @return Deferred
|
|
|
|
|
*/
|
2016-06-23 20:42:50 +08:00
|
|
|
const std::shared_ptr<Deferred> &DeferredConsumer::reportSuccess(const std::string &name)
|
2014-04-15 17:39:52 +08:00
|
|
|
{
|
2016-06-23 20:42:50 +08:00
|
|
|
// we now know the name, so install ourselves in the channel
|
|
|
|
|
_channel->install(name, shared_from_this());
|
|
|
|
|
|
2014-04-15 17:39:52 +08:00
|
|
|
// skip if no special callback was installed
|
|
|
|
|
if (!_consumeCallback) return Deferred::reportSuccess();
|
2016-06-23 20:42:50 +08:00
|
|
|
|
2014-04-15 17:39:52 +08:00
|
|
|
// call the callback
|
|
|
|
|
_consumeCallback(name);
|
2016-06-23 20:42:50 +08:00
|
|
|
|
2014-04-15 17:39:52 +08:00
|
|
|
// return next object
|
|
|
|
|
return _next;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-23 20:42:50 +08:00
|
|
|
/**
|
2016-09-11 02:36:06 +08:00
|
|
|
* Announce that a message was received
|
|
|
|
|
* @param message The message to announce
|
2016-06-23 20:42:50 +08:00
|
|
|
* @param deliveryTag The delivery tag (for ack()ing)
|
|
|
|
|
* @param redelivered Is this a redelivered message
|
|
|
|
|
*/
|
2017-03-08 20:32:51 +08:00
|
|
|
void DeferredConsumer::announce(const Message &message, uint64_t deliveryTag, bool redelivered) const
|
2016-06-23 20:42:50 +08:00
|
|
|
{
|
|
|
|
|
// simply execute the message callback
|
2017-03-08 20:32:51 +08:00
|
|
|
_messageCallback(message, deliveryTag, redelivered);
|
2016-06-23 20:42:50 +08:00
|
|
|
}
|
|
|
|
|
|
2014-04-15 17:39:52 +08:00
|
|
|
/**
|
|
|
|
|
* End namespace
|
|
|
|
|
*/
|
|
|
|
|
}
|