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

Add Quartz StartupDelay option #3454

Merged
merged 3 commits into from
Apr 11, 2020
Merged

Add Quartz StartupDelay option #3454

merged 3 commits into from
Apr 11, 2020

Conversation

olicooper
Copy link
Contributor

No description provided.

@maliming maliming added this to the 2.5 milestone Apr 3, 2020
@maliming
Copy link
Member

maliming commented Apr 3, 2020

hi @olicooper
Can you talk about a use case? Although I know that tasks can be delayed, why are they delayed in ABP?

@realLiangshiwei
Copy link
Member

@olicooper Hi ,I see the StartDelayed method for those applications that need to be initialized, but the service registration of the ABP framework is completed before OnApplicationInitialization. I don't think it is necessary to add this option. Can you introduce other usage case?

@olicooper
Copy link
Contributor Author

@maliming my use case for this is that I need some jobs to run before any Quartz jobs and I also want to give the rest of the system time to load before jobs are loaded and configured (as they are less important than other core areas of the system).

@maliming
Copy link
Member

maliming commented Apr 3, 2020

Quartz's delay is just Task.Delay. Can't you implement it yourself?

https://github.com/quartznet/quartznet/blob/b2b655db1819c8d8256981e2865ebf30433ec0fb/src/Quartz/Core/QuartzScheduler.cs#L398

And StartupDelay is a global configuration, it should support each task to configure its own delay time. We can add the AbpQuartzDelayAttribute and then OnApplicationInitialization method to delay startup according the attribute.

@olicooper
Copy link
Contributor Author

When Jobs are persisted in a database the previously saved start/end times tell Quartz if the job failed to run (due to down time etc). By adding a start delay to the whole Quartz scheduler, we delay all of the database queries that Quartz executes to restart those jobs which reduces the burden when the system starts.

I don't think I am able to add the Task.Delay to the Quartz module unless I override AbpQuartzModule.OnApplicationInitialization and provide my own implementation, but this seems overkill.

@olicooper Hi ,I see the StartDelayed method for those applications that need to be initialized, but the service registration of the ABP framework is completed before OnApplicationInitialization. I don't think it is necessary to add this option. Can you introduce other usage case?

^^ @liangshiw Sorry, I am not sure what you mean by this. I don't think the scheduler starts to process jobs until the Start/StartDelayed method is called, so StartDelayed should be okay to call even if Quartz has already been registered in OnApplicationInitialization.

@maliming maliming requested a review from hikalkan April 8, 2020 02:08
@ebicoglu ebicoglu modified the milestones: 2.5, 2.6 Apr 10, 2020
@hikalkan hikalkan merged commit ff032d8 into abpframework:dev Apr 11, 2020
@hikalkan
Copy link
Member

Thanks.

@olicooper olicooper deleted the olicooper/quartz-startup-delay branch April 19, 2020 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants