Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple instances of AutomaticRetryAttribute are not allowed #2507

Open
FixRM opened this issue Mar 27, 2025 · 0 comments
Open

Multiple instances of AutomaticRetryAttribute are not allowed #2507

FixRM opened this issue Mar 27, 2025 · 0 comments

Comments

@FixRM
Copy link

FixRM commented Mar 27, 2025

Hello, and thank you for a great tool!

I'm trying to achieve two goals:

  1. All failed jobs must be transitioned to deleted state
  2. Retries must happen only for specific exception types

I tried the flowing:

GlobalJobFilters.Filters.Remove(typeof(AutomaticRetryAttribute));
GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute()
{
    OnAttemptsExceeded = AttemptsExceededAction.Delete,
    OnlyOn = [ typeof(OperationCanceledException) ]
});
GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute()
{
    Attempts = 0,
    OnAttemptsExceeded = AttemptsExceededAction.Delete
});

Retry works but jobs with other types of errors goes to "Failed" state instead of "Deleted".

Then I tried the following:

GlobalJobFilters.Filters.Remove(typeof(AutomaticRetryAttribute));
GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute()
{
    Attempts = 0,
    OnAttemptsExceeded = AttemptsExceededAction.Delete
});
GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute()
{
    OnAttemptsExceeded = AttemptsExceededAction.Delete,
    OnlyOn = [ typeof(OperationCanceledException) ]
});

In this case all failed jobs goes to deleted without any retry.

I guess the problem is that only one instance of each attribute type is enabled?

@FixRM FixRM changed the title Multiple instances of AutomaticRetryAttribute are not enabled Multiple instances of AutomaticRetryAttribute are not allowed Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant