jhipster-dotnetcore
jhipster-dotnetcore copied to clipboard
Add possibility to schedule jobs
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)
Do you need jhipster for that ? You can use https://www.hangfire.io/.
https://www.hangfire.io/
i think embed in jhipster generator like Quartz.net is simpler than hangfire. Thanks
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
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
If you need pre-made it's ok for me Do you want work on it ?
If you need pre-made it's ok for me Do you want work on it ?
ok ,i hope i can do it .
If you need help, don't hesitate to ping me
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.
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
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).
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/
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.