Hi Sean, you have a few options here:
- You can subscribe to the
OnMessageSentToErrorQueue
event and send/publish from there.
var endpointConfiguration = new EndpointConfiguration("MyEndpoint");
endpointConfiguration.UseTransport<LearningTransport>();
IMessageSession messageSession = null;
endpointConfiguration.Recoverability().Delayed(s => s.NumberOfRetries(0));
endpointConfiguration.Recoverability()
.Failed(s => s.OnMessageSentToErrorQueue(fm =>
{
var options = new SendOptions();
options.RequiredImmediateDispatch();//to make sure the send operation doesn't participate in the receive transaction
options.SetDestination("SomeOtherEndpoint");
return messageSession.Send(new ReportThatMessageFailed
{
Reason = fm.Exception.Message
}, options);
}));
messageSession = await Endpoint.Start(endpointConfiguration)
.ConfigureAwait(false);
Note the call to RequiredImmediateDispatch
to make sure that the operation doesn’t enlist in the current receive transaction to make sure that it gets sent our no matter what.
-
Subscribe to the
MessageFailed
event from ServiceControl, see Using ServiceControl Events • ServiceControl Contracts • Particular Docs -
Depending on the business requirements potentially use a saga to control the retry behaviour and report various statuses back to other endpoints. See Sagas • NServiceBus • Particular Docs
Can you share some more details on why you need to report that the message was moved to the error queue to other endpoints?
Cheers,
Andreas