jhipster-dotnetcore icon indicating copy to clipboard operation
jhipster-dotnetcore copied to clipboard

Add possibility to schedule jobs

Open manisi opened this issue 4 years ago • 12 comments

Overview of the feature request

for execute certain task in the background that should be executed at predefined intervals of time .

Motivation for or Use Case
Related issues or PR
  • [ ] Checking this box is mandatory (this is just to show you read everything)

manisi avatar Nov 18 '20 06:11 manisi

Do you need jhipster for that ? You can use https://www.hangfire.io/.

nicolas63 avatar Nov 18 '20 06:11 nicolas63

https://www.hangfire.io/

i think embed in jhipster generator like Quartz.net is simpler than hangfire. Thanks

manisi avatar Nov 18 '20 06:11 manisi

Yes maybe, but what is the added value of generating this part ? Add the nuget and expose the configuration ? If it's just for that I think developers can do it

nicolas63 avatar Nov 18 '20 06:11 nicolas63

some time the first generated jhipster app need to use execute jobs. for example : the not active user must be deleted before 2 days ago. and the other hand yes add nuget package and use it. Thanks

manisi avatar Nov 18 '20 06:11 manisi

If you need pre-made it's ok for me Do you want work on it ?

nicolas63 avatar Nov 18 '20 07:11 nicolas63

If you need pre-made it's ok for me Do you want work on it ?

ok ,i hope i can do it .

manisi avatar Nov 18 '20 07:11 manisi

If you need help, don't hesitate to ping me

nicolas63 avatar Nov 18 '20 07:11 nicolas63

We can use integrated .Net Core HostedService to implement background task rather than use of external package

And use of Cronos package to parse Cron expressions and calculating next occurrences.

maznag avatar Jan 21 '21 20:01 maznag

the main advantage of the hangfire is that you can also have an admin part with the cron states, monitoring etc... The persistence of the jobs is also a good feature

nicolas63 avatar Jan 21 '21 21:01 nicolas63

It would be interesting if the job scheduler could work properly when we horizontally scale the application (running the app on 3 servers, as example). We don't want the same job running on all servers. That would waste resources and lead to problems.

It seems that hangfire.io supports this scenario: https://docs.hangfire.io/en/latest/background-processing/running-multiple-server-instances.html

What I have not liked about hangfire.io is that the supported storage options are MSSQL and Redis only (https://docs.hangfire.io/en/latest/#job-storage). But I'm not sure it is a problem. I have not used hangfire.io before.

Edit: It seems that hangfire.io supports many persistent storage options (https://www.hangfire.io/extensions.html).

ivanmonteiro avatar Jan 21 '21 22:01 ivanmonteiro

Quartz.Net also seems interesting and worth investigating. It supports job persistence (in memory and database by ado.net), fail retry and, clustering (multi-server). See: https://www.quartz-scheduler.net/

ivanmonteiro avatar Jan 22 '21 00:01 ivanmonteiro

My opinion is that the job shceduling solution should:

  • start simple (no need of dependency on redis or external server at first)

And allow more complex scenarios such as:

  • (optionally?) allow persistence - adds robustness tor the application and is useful for server reboots, failover and retry
  • (optionally?) work on multi-server applications. This is optional, but it is important for scalability.

Both hangfire.io and Quartz.Net seems to have its pros and cons. Quartz.Net seems simple at first with in-memory persistence. Hangfire.io has more features (dashboard, etc) but the basic setup seems more complex as it needs eiher Redis or database persistence.

@maznag @nicolas63 You both have interesting ideas, please share what you think.

ivanmonteiro avatar Jan 22 '21 00:01 ivanmonteiro