0

I tried to copy a custom headers from the incoming pipeline to de outgoin pipeline with the purpose of spread this headers along all services. This has been implemented using the behaviors pipeline. The problem is in the outgoing context the headers is no present. I resolve it using a cache a get this data from the cache in the outgoingphisical context. Anyone does kown a better way where the cache it not necesary? Thanks.

1 Answers1

1

Using extension bag (Extensions property on the behaviour's context object) is a good option. You can set the value in the incoming pipeline behavior and reference it later in the outgoing pipeline behavior.

The Audit Filter Pipeline Extension sample on the documentation site demonstrates how to extend the NServiceBus message-processing pipeline with custom behaviors to add filters which prevent certain message types from being forwarded to the audit queue. In your case, you'd be storing the incoming message header and using it in the outgoing behavior(s)

Sean Feldman
  • 23,443
  • 7
  • 55
  • 80
  • Sean knows what he's talking about and he even stays up late at night to answer your questions! ;-) Here's a sample I created a long time ago that reads a specific BusinessCorrelationId from headers and adds it to any outgoing messageheaders as well: https://github.com/dvdstelt/NServiceBus-Samples/tree/master/samples/LoggingCorrelationId Just look at the two behaviors, that's all there's to it. – Dennis van der Stelt Jan 20 '22 at 09:59
  • Great example, @DennisvanderStelt. – Sean Feldman Jan 20 '22 at 15:44
  • Thank you all. This seems to be just what I need. I'll do a test and let you know the results. – Rubén Carretero Jan 24 '22 at 07:52
  • Using extensions works fine. Thanks! – Rubén Carretero Jan 24 '22 at 12:14