Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rabbit MQ .Net Client 6.1 - Basic Properties Headers are null

I was previously using version 5 of the .NET client api for Rabbit. I would send me messages with custom header by using code similar to this:

        IBasicProperties messageProperties = null;
        lock (connectLock)
        {
            messageProperties = this._channel.CreateBasicProperties();
        }
        messageProperties.Headers = new Dictionary<string, object>(5);

then I would do a BasicPublish, passing the messageProperties object and message body.

my consumer received event would then retrieve the headers from the basic delivery event args i.e.

    void consumer_Received(object sender, BasicDeliverEventArgs e)
    {
        var headers = e.BasicProperties.Headers;

However, after I upgraded to the 6.1 library....the Headers object is always NULL.

is there now a different way to retrieve headers using the 6.1 library?

like image 904
Martywaz Avatar asked Feb 09 '26 20:02

Martywaz


1 Answers

Thereis a boolean property IsHeadersPresent which you should possibly check before attempting to access the Headers Collection.

I have a similar problem except I want to add a new Header, I don't really want to have to initialise the Headers Collection myself...

like image 61
Barry Wimlett Avatar answered Feb 12 '26 16:02

Barry Wimlett



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!