Skip to content

Multiple instances of AutomaticRetryAttribute are not allowed #2507

Open
@FixRM

Description

@FixRM

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions