Simple .NET event listener-based callbacks for common Rebus hooks
$ dotnet add package Rebus.EventsProvides configuration extensions that allow for easily hooking into Rebus in various places.
Here is how you would add custom headers to all outgoing messages:
Configure.With(...)
.(...)
.Events(e =>
{
e.BeforeMessageSent += (bus, headers, message, context) =>
{
headers["x-custom-header"] = "wohoo";
};
});
The following events are available:
BeforeMessageSent: Raised before each message is sent, allowing for mutating the message and even replacing it with something else if you wantAfterMessageSent: Raised after each message has been sent (or added to the transaction's list of outgoing messages)BeforeMessageHandled: Raised before an incoming message is dispatched to handlersAfterMessageHandled: Raised after an incoming message is dispatched to handlers