CopernicaMarketingSoftware / AMQP-CPP

C++ library for asynchronous non-blocking communication with RabbitMQ
Apache License 2.0
884 stars 340 forks source link

How to set a boolean field in a header? #535

Open TrueWodzu opened 1 month ago

TrueWodzu commented 1 month ago

Hello,

I am struggling to send in a header a custom field with value: true or false. Is there a support for simple boolean values?

Here is what I am trying:

    AMQP::MetaData metadata;
    AMQP::Table table;
    table.set("compressed", false);
    table.set("encrypted", true);
    metadata.setHeaders(table);

I see that the message with these custom fields has been send properly, but I couldn't find a way to get back these fields:

.onReceived([&channel, queue_name, this](const AMQP::Message &message, uint64_t deliveryTag, bool redelivered)
            {
                message.headers().get("compressed").isBoolean(); // Returns true
                message.headers().get("encrypted").isBoolean(); // Returns true
                auto a = message.headers().get("encrypted").operator int8_t(); // Returns 0 should return 1
                auto b = message.headers().get("compressed").operator int8_t(); // Returns 0

                channel.ack(deliveryTag);
            })