Reputation: 83
Hangfire DisableConcurrentExecution attribute was never called
As per documentation, I have a method that can be called with a different Id and run concurrently. However, I want to stop the method from running concurrently if it's the same Id that being passed. I tried multiple things but the disableconcurrentexecution attribute was just never called. I assume it would work but for some reasons the attribute just didn't get called.
public void ScheduleUpsertMethod(int Id)
{
var result = _scheduler.Schedule<Account>(service =>
service.doSomething(Id));
}
[AutomaticRetry(OnAttemptsExceeded = AttemptsExceededAction.Fail, Attempts = 3, LogEvents = true)]
[DisableConcurrentExecution 5*60]
public async Task doSomething(int Id)
{
}
Upvotes: 5
Views: 2048
Reputation: 83
I'm answering my own question here since nobody has replied. I made a mistake of putting the DisableConcurrentExecution with the method. Account is actually an interface and I had to put the DisableConurrentExecution inside the Account Interface for the attribute to be triggered.
Upvotes: 2