Search code examples
rebus

Setting a custom return address header


I need to set a custom return-address as described here https://github.com/rebus-org/Rebus/wiki/Return-addresses but there's no attachheader option anymore.

How do I achieve this in rebus2?


Solution

  • All methods on IBus that send messages have an optional parameter that accepts a headers dictionary.

    Therefore, you can simply

    var headers = new Dictionary<string, string> {
        { Headers.ReturnAddress, "wherever" }
    };
    
    await bus.Send(yourMessage, headers);
    

    in order to set a custom return address :)