Created
September 25, 2012 11:49
-
-
Save andreasohlund/3781308 to your computer and use it in GitHub Desktop.
How to turn SLR of for a given exception type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ChangeRetryPolicy : INeedInitialization | |
{ | |
public void Init() | |
{ | |
SecondLevelRetries.RetryPolicy = (tm) => | |
{ | |
// retry max 3 times | |
if (TransportMessageHelpers.GetNumberOfRetries(tm) >= 3) | |
{ | |
// To send back a value less than zero tells the | |
// SecondLevelRetry satellite not to retry this message | |
// anymore. | |
return TimeSpan.MinValue; | |
} | |
if (tm.Headers["NServiceBus.ExceptionInfo.ExceptionType"] == typeof(MyBusinessException).FullName) | |
return TimeSpan.MinValue; | |
return TimeSpan.FromSeconds(5); | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment