Vancouverite
Vancouverite

Reputation: 3

How to set a different MaxRetries per message type at any given Endpoint in NService bus?

I have a requirement for an endpoint to receive commands from a client and also to subscribe to events from another endpoint such as:

1- the received command is tried only once then sent to the error queue if an exception occurred

2- the received event is tried indefinitely until it is processed

Could the MaxRetries bet set differently depending on the message type?

Upvotes: 0

Views: 659

Answers (2)

John Simons
John Simons

Reputation: 4288

NServiceBus MaxRetries setting is to handle things like deadlocks, so not really what you want for this scenario.

What you want is to use SLRs to handle this situation.

To filter based on an exception type, have a look at http://andreasohlund.net/2012/09/26/disabling-second-level-retries-for-specific-exceptions/

Hope this helps!

Upvotes: 1

Sławomir Rosiek
Sławomir Rosiek

Reputation: 4073

I looked into NSB source and I notice that MaxRetries can't take different values for different messages in NSB 3.3. Happily you can override class that forward messages to error queue and implement your own version that checking if failed message is event and then instead forward to error queue you can send it again to current endpoint.

Upvotes: 1

Related Questions