amqpcpp icon indicating copy to clipboard operation
amqpcpp copied to clipboard

duplicate call amqp_channel_close, it is not necessary

Open fxconfig opened this issue 6 years ago • 0 comments

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);

};

fxconfig avatar Sep 12 '17 10:09 fxconfig