MassTransit: Adding Headers to Publish Pipeline

后端 未结 1 1780
盖世英雄少女心
盖世英雄少女心 2021-01-12 23:33

I\'m using MassTransit 3.2.4 and I\'m trying to add some header information for to my published messages but the code to set the header never seems to run. I\'m not sure why

相关标签:
1条回答
  • 2021-01-13 00:15

    Figured it out after much guessing. Just had the ConfigurePublish in the wrong place

    var bus = Bus.Factory.CreateUsingRabbitMq(config => 
    {
        var host = config.Host(new Uri("rabbitmq://localhost/"), h => {});
        config.ConfigurePublish(x => x.UseSendExecute(context => 
        {
            context.Headers.Set("HeaderKey", "HeaderValue");
        }));
    }
    
    0 讨论(0)
提交回复
热议问题