0
votes

Is it posible to say NSB to copy all message headers from command message to reply? By default NSB copy its own headers NSwerviceBus.*, but not custom.

Here is my case: I have a saga and a set of workers. Saga sends messages to workers through distributor. For some reasons workers cannot process some messages. It doesn't fail and just reply to saga with specific reply: CannotProcessMessage.

What i want is to process each command 3 times (Saga should correlate this, not NSB retry mechanism). I see 3 solutions:

  1. Hold a dictionary of attempt count for each message is SagaData. This solution is not very good because in case of mullions of messages sagadata will become very large

  2. Add a property "AttemptCount" to my message and my reply. This will work, but will affect my workers interface. Workers should not know anything about attempt count

  3. Add "AttemptCount" to command and reply headers. It will not affect workers interface, but stil we have to copy this header from command to reply in worker.

So, a found third is the best soulution, but can't find a way to say NSB to automatically copy headers from command to reply. Is it posible? Or maybe you can suggest other solutions?

Thanks.

1

1 Answers

1
votes

You can use message mutators (or the new behavior pipeline in v5) to perform that header-copying functionality, package that in its' own assembly, and then deploy that as a part of each worker.