Use this feature to forward successfully processed messages from an endpoint to a specific destination endpoint for additional processing. Forwarding messages can be particularly useful in complex upgrade scenarios.
Forwarding a message from the handler
Individual messages can be forwarded directly from the handler:
await context.ForwardCurrentMessageTo("destinationQueue@machine");
Forwarding should not be used to abort message processing in the handler. Messages cannot be forwarded to the error
queue as the required metadata for failed messages would not be present in the forwarded message's metadata. Attempting to use forwarding as a mechanism to abort processing can result in partial updates.
Instead, throw an exception in the message handler. This ensures that no ghost messages are transmitted and any transactional state changes are rolled back.
To prevent unnecessary retries, declare an unrecoverable exception or create a custom recoverability policy.
Auditing vs. Forwarding
Auditing and Forwarding are very similar. Both send a copy of the processed message to another queue. The main difference is the intended usage scenarios.
Auditing is an implicit per-message operation configured at the endpoint level. An audit message is automatically enriched with additional information regarding its processing for ingestion by ServiceControl Audits.
Message forwarding is an explicit per-message operation from your handler, enabling additional custom processing for your system needs.
The forwarded messages do not contain the audit message headers.