Message forwarding

Component: NServiceBus
NuGet Package NServiceBus (7.4)

Use this feature to forward successfully processed messages from an endpoint to a specific destination endpoint. Forwarding messages is particularly useful in complex upgrade scenarios, when the old version and new version of a particular endpoint are running side-by-side.

Auditing vs Forwarding

Auditing and Forwarding are very similar, both send a copy of the processed message to another queue. The main difference are intended usage scenarios.

Auditing is used for collecting information on what is happening in the system, therefore the audited message is enriched with additional information regarding processing of it. Forwarding would send a copy of the processed message, without the additional auditing information.

The forwarded messages do not contain the audit message headers.

Forwarding every message processed

Forwarding a copy of every processed message is no longer supported and will be removed in NServiceBus version 8. See message forwarding for an example of how to achieve this with a custom pipeline behavior.

Using code

endpointConfiguration.ForwardReceivedMessagesTo("destinationQueue@machine");

Forwarding a message from the handler

Individual messages can be forwarded directly from the handler:

await context.ForwardCurrentMessageTo("destinationQueue@machine")
    .ConfigureAwait(false);

Related Articles

  • Auditing Messages
    Configure where to send messages and it provides built-in message auditing for every endpoint.

Last modified