jhipster / jhipster-dotnetcore

JHipster.NET blueprint
Apache License 2.0
308 stars 93 forks source link

Add possibility to schedule jobs #466

Open manisi opened 3 years ago

manisi commented 3 years ago
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
nicolas63 commented 3 years ago

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

manisi commented 3 years ago

https://www.hangfire.io/

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

nicolas63 commented 3 years ago

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

manisi commented 3 years ago

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

nicolas63 commented 3 years ago

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

manisi commented 3 years ago

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

ok ,i hope i can do it .

nicolas63 commented 3 years ago

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

maznag commented 3 years ago

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.

nicolas63 commented 3 years ago

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

ivanmonteiro commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

My opinion is that the job shceduling solution should:

And allow more complex scenarios such as:

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.