Adding values to header in MassTransit.RabbitMq -


i using masstransit 3.0.0.0 , have hard time understanding how intercept messages in request-response scenario, on way out , add information headers field, that, , can read on receiver's end.

i looking @ middleware, recommended in masstransit docs - see observers warning - context on send pipe context doesn't have access headers field cannot alter it. used sample provided in middleware page.

i then, looked @ ipublishinterceptor

public class x<t> : ipublishinterceptor<t> t : class, pipecontext {     public task postpublish(publishcontext<t> context)     {         return new task(() => { });     }      public task postsend(publishcontext<t> context, sendcontext<t> sendcontext)     {         return new task(() => { });     }      public task prepublish(publishcontext<t> context)     {         context.headers.set("id", guid.newguid().tostring());         return new task(() => { });     }      public task presend(publishcontext<t> context, sendcontext<t> sendcontext)     {         context.headers.set("id", guid.newguid().tostring());         return new task(() => { });     } } 

which clear , concise. don't know used , how link rest of infrastructure. stands, interface not linked anything.

if need add headers when message being sent, can add middleware components either send or publish pipeline shown below. note send filters apply messages, whereas publish filters apply messages published.

// execute synchronous delegate on send cfg.configuresend(x => x.execute(context => {}));  // execute synchronous delegate on publish cfg.configurepublish(x => x.execute(context => {})); 

the middleware can configured on either bus or individual receive endpoints, , configurations local it's configured.


Comments