amqpcpp
amqpcpp copied to clipboard
duplicate call amqp_channel_close, it is not necessary
an AMQP can manager several Exchanges Or QUEUEs. every of them have their own channel, right?
if I call delete AMQP* directly, in the Destructor channels.size() is not zero, but AMQPBase* in the vector is un-reachable. the delete *i would throw;
So I suggest call AMQP::closeChannel() in its Destructor.
AMQPBase::~AMQPBase() { this->closeChannel(); }
AMQP::~AMQP() { if (channels.size()) { vector<AMQPBase*>::iterator i; for (i=channels.begin(); i!=channels.end();) { delete *i; } }
amqp_channel_close(cnn, 1, AMQP_REPLY_SUCCESS);
amqp_connection_close(cnn, AMQP_REPLY_SUCCESS);
amqp_destroy_connection(cnn);
};