Skip to content

AMQP-CPP 2.1.3

Compare
Choose a tag to compare
@EmielBruijntjes EmielBruijntjes released this 20 Aug 13:07
· 845 commits to master since this release

This is mainly a bug fix release, and a couple of extra methods have been added to the Connection class.

New features
The Connection class now has methods "login()" and "vhost()" to retrieve the login and the vhost that were passed in when the object was constructed.

Bug fix: channels were not correctly queueing instructions
It turned out that when a Channel object was destructed before it had sent all instructions over the connection, the unsent instructions were lost. This was incorrect behavior of the Channel class - which is supposed to be a class that can be used in a local scope to group instructions. The following code was not working:

void myfunc(AMQP::Connection *connection)
{
    AMQP::Channel channel(connection);
    channel.declareQueue("my-queue");
    channel.bindQueue("my-exchange", "my-queue", "my-routing-key");
    channel.publish("my-exchange", "my-routing-key", "my-message");
    channel.get("my-queue").onSuccess([](const Message &message, uint64_t deliveryTag, bool redelivered) {
        // @todo deal with the message
    });
}

The above code above was not behaving the way you would expect: the queue was not bound, and no messages were published or received. This bug occured because the channel object falls out of scope and is destructed before all instructions are sent, and before the confirmations from RabbitMQ are received. This has now been fixed: all method calls on a channel object will now be sent to RabbitMQ, even when the channel object falls out of scope before the confirmations come back from RabbitMQ. It is thus now possible to use AMQP::Channel objects as local variables to group instructions.