2014-01-06 22:49:31 +08:00
|
|
|
/**
|
|
|
|
|
* Base class for a message implementation
|
|
|
|
|
*
|
|
|
|
|
* @copyright 2014 Copernica BV
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set up namespace
|
|
|
|
|
*/
|
|
|
|
|
namespace AMQP {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class definition
|
|
|
|
|
*/
|
|
|
|
|
class ConsumedMessage : public MessageImpl
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
/**
|
|
|
|
|
* The consumer tag
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
std::string _consumerTag;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The delivery tag
|
|
|
|
|
* @var uint64_t
|
|
|
|
|
*/
|
|
|
|
|
uint64_t _deliveryTag;
|
2014-04-10 18:51:04 +08:00
|
|
|
|
2014-01-06 22:49:31 +08:00
|
|
|
/**
|
|
|
|
|
* Is this a redelivered message?
|
|
|
|
|
* @var bool
|
|
|
|
|
*/
|
|
|
|
|
bool _redelivered;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
/**
|
|
|
|
|
* Constructor
|
|
|
|
|
* @param frame
|
|
|
|
|
*/
|
2014-04-10 18:51:04 +08:00
|
|
|
ConsumedMessage(const BasicDeliverFrame &frame) :
|
|
|
|
|
MessageImpl(frame.exchange(), frame.routingKey()),
|
2014-01-06 22:49:31 +08:00
|
|
|
_consumerTag(frame.consumerTag()), _deliveryTag(frame.deliveryTag()), _redelivered(frame.redelivered())
|
|
|
|
|
{}
|
2014-04-10 18:51:04 +08:00
|
|
|
|
2014-01-06 22:49:31 +08:00
|
|
|
/**
|
|
|
|
|
* Destructor
|
|
|
|
|
*/
|
|
|
|
|
virtual ~ConsumedMessage() {}
|
2014-04-10 18:51:04 +08:00
|
|
|
|
2014-01-06 22:49:31 +08:00
|
|
|
/**
|
|
|
|
|
* Report to the handler
|
2014-04-10 18:51:04 +08:00
|
|
|
* @param consumer
|
2014-01-06 22:49:31 +08:00
|
|
|
*/
|
2014-04-10 18:51:04 +08:00
|
|
|
virtual void report(const DeferredConsumer& consumer) override
|
2014-01-06 22:49:31 +08:00
|
|
|
{
|
2014-04-10 18:51:04 +08:00
|
|
|
// send ourselves to the consumer
|
|
|
|
|
consumer.message(*this, _deliveryTag, _consumerTag, _redelivered);
|
2014-01-06 22:49:31 +08:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* End of namespace
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|