I implemented QuartzBackgroundWorkerBase for my background worker.
The trigger code is this:
Trigger = TriggerBuilder.Create()
.WithDailyTimeIntervalSchedule(
builder => builder.StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(X, Y)).EndingDailyAfterCount(1))
.Build();
Worker triggers the job one time,
but Execute method runs 3 times even i used [DisallowConcurrentExecution]
attribute for the worker class.
I tried many scheduler combinations, but without success.
What can be the problem? It looks like a threading issue. I don't think the problem is with Quartz framework.
14 Answer(s)
-
0
I will check this.
-
0
I am in version 2.4.0.
-
0
-
0
I am trying to reproduce or fix this. Thanks. I am in version 2.4.0. I will update the framework and check again.
-
0
Did you reproduce the problem? I tested version v2.4, It works fine.
-
0
Hello @liangshiwei,
I reproduce the problem in 2.6.2. I have a sample project. How can i share it to you?
Thanks.
-
0
liangshiw@outlook.com
You can send a email to me.
-
0
Hi @talhazengin
I checked your code. You added workers repeatedly.
Quartz integration will automatically add workers, See Source Code. So, for quartz you don't need to add it manually.
There is another reason for repetition. You did not specify the job identity, for quartz, it is two different jobs.
In the next version, there will be an option to disable automatic add. See https://github.com/abpframework/abp/pull/3382.
-
0
Quartz specifies the job identity as GUID itself. So why we need to supply it explicitly?
You are right, i added extra registiration with below line of code: context.AddBackgroundWorker<MyQuartzWorker>(); When we remove this, repeated registration problem is gone.
But there is another problem going on: When we start Host project with separated IdentityServer project, now it runs 2 times :( IdentityServer project registers the Quartz again. How is this possible? IdentityServer project includes reference to Domain project, maybe this can cause this.
Thanks for your helps
-
0
Ok i found it,
Below line should be in Host project, should not be in Domain project. [DependsOn(typeof(AbpBackgroundWorkersQuartzModule)
Thanks.
-
0
For quartz, it is two different jobs.
If you want to add only one background worker instance, you should specify Job Identity, See https://www.quartz-scheduler.net/documentation/quartz-3.x/tutorial/index.html for more information.
But if you use persistent storage, it throws an exception, you can add the following code to your project : https://github.com/liangshiw/AbpVnextQuartzBackground/blob/master/QuartzBackgroundWorkerManager.cs.
You need to pay attention, if your periodic work is missed multiple times, it will only try to execute it for you once.
You can track this PR : https://github.com/abpframework/abp/pull/3382.
-
0
I am not clearly understand the concept of the jobkey and its integration with abp forgive me.
.WithIdentity(nameof(MyWorker)) is this enough for my case?
JobDetail = JobBuilder.Create<MyWorker>() .WithIdentity(nameof(MyWorker)) .Build(); Trigger = TriggerBuilder.Create() .WithIdentity(nameof(MyWorker)) .WithDailyTimeIntervalSchedule( builder => builder.StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(0, 1)) .EndingDailyAfterCount(1)) .Build();
-
0
Yes this is enough. If you still have problems, I can help you remotely.
-
0
That's enough for now :) We don't have much time. I am closing this issue, if i need further assistance, i can open a new thread. Thank you.