elsa-workflows / elsa-core

A .NET workflows library
https://v3.elsaworkflows.io/
MIT License
6.24k stars 1.14k forks source link

Quartz Scheduler is not working in v3 #4818

Closed NightWuYo closed 6 months ago

NightWuYo commented 7 months ago

In Elsa v3.0.3, I added below code, but the Timer is never triggered.

For Hangire, we have runtime.UseHangfireBackgroundActivityScheduler(), which uses Hangfire to schedule background activities. But I did not find a similar funciton for Quartz.

// Use timers. elsa.UseQuartz(); elsa.UseScheduling(scheduling => scheduling.UseQuartzScheduler());

stevetayloruk commented 7 months ago

+1 on this for us too.

sfmskywalker commented 7 months ago

It seems you're trying to use Quartz.NET for scheduling background activities in Elsa 3, similar to what Hangfire offers. You're looking to replace Hangfire's background activity scheduling with Quartz.NET, but facing the fact that there is no such implementation for IBackgroundActivityScheduler. Is that right?

NightWuYo commented 7 months ago

@sfmskywalker Basically, it's right. The main issue is, with Quartz.NET, the timer is not triggered at all.

I tried Quartz.NET because Hangfire is not working (every instance will trigger timer even the Hangfire is configured to use Redis). Maybe it's because I did not configure it correctly.

The key requirement is, when we have multiple Elsa Server instances, the timers/scheduler can be triggered correctly. Providing working samples would be great.

NightWuYo commented 7 months ago

Sorry, I'm not trying to "use Quartz.NET for scheduling background activities". I have created some workflows through Studio, and these workflows start with a Timer. I want those Timers/Workflows to be scheduled correctly, when multiple Elsa Servers are deployed.

NightWuYo commented 7 months ago

Either Hangfire or Quartz, I just want the scheduler to work correctly (for workflows created in Studio, and starts with a Timer), when multiple instances are running. So Each single workflow will be run exact once at certain time (based on the Timer).

Currently neither of them are working:

  1. With hangfire, the Timer is triggered from all the instances, although I have configured to use the Redis storage.
  2. For Quartz, Timer is never triggered, check https://github.com/elsa-workflows/elsa-core/issues/4818, I guess it's because we lack of UseQuartzBackgroundActivityScheduler (which is not implemented), but not sure.

@sfmskywalker May I request to prioritize this issue? Providing a working sample project would be good enough.

Otherwise we have to implement an indenpendant service as a Timer and then trigger workflows by HttpEndPoint or MassTransit Message.

sfmskywalker commented 7 months ago

Thank you for highlighting the issue with Quartz and Hangfire schedulers. I understand the critical nature of this problem for running workflows reliably across multiple instances. While I'd like to address this promptly, my current workload, primarily from commitments to paying customers, limits my immediate availability to tackle this issue in-depth.

I recognize the importance of a working scheduler and will aim to revisit this as soon as possible. In the meantime, I encourage community contributions and discussions for potential workarounds or solutions. Thanks for understanding.

mohdali commented 6 months ago

Either Hangfire or Quartz, I just want the scheduler to work correctly (for workflows created in Studio, and starts with a Timer), when multiple instances are running. So Each single workflow will be run exact once at certain time (based on the Timer).

Currently neither of them are working:

  1. With hangfire, the Timer is triggered from all the instances, although I have configured to use the Redis storage.
  2. For Quartz, Timer is never triggered, check https://github.com/elsa-workflows/elsa-core/issues/4818, I guess it's because we lack of UseQuartzBackgroundActivityScheduler (which is not implemented), but not sure.

@sfmskywalker May I request to prioritize this issue? Providing a working sample project would be good enough.

Otherwise we have to implement an indenpendant service as a Timer and then trigger workflows by HttpEndPoint or MassTransit Message.

When you have multiple servers and want Quartz to work properly you should add some persitence to elsa.UseQuartz() call using the database of your preferences. There were some issue with MySQL/Postgres/SQLServer but those should be already fixed in recent previews.

NightWuYo commented 4 months ago

Just got a chance to test, the Quartz scheduler is working now.