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

[BUG] Timer Trigger not respecting SingletoneStrategy #5308

Open
wseegersatdealx opened this issue Apr 30, 2024 · 3 comments
Open

[BUG] Timer Trigger not respecting SingletoneStrategy #5308

wseegersatdealx opened this issue Apr 30, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@wseegersatdealx
Copy link

wseegersatdealx commented Apr 30, 2024

Description

The timer trigger does not seem to respect the SingletoneStrategy.

Elsa v3.1.3

Steps to Reproduce

Due to a bug with the default scheduler where it doubles on each trigger instance I used the quartz scheduler.

    // ...
    elsa.UseQuartz();
    elsa.UseScheduling(x => x.UseQuartzScheduler());
});

Using the Elsa.Samples.AspNet.Heartbeats project and updating the HeartbeatWorkflow to the following.

public class HeartbeatWorkflow : WorkflowBase
{
    protected override void Build(IWorkflowBuilder builder)
    {
        builder.Root = new Sequence
        {
            Activities =
            {
                new Timer(5.Seconds())
                {
                    CanStartWorkflow = true
                },
                new WriteLine(context => $"Start {context.GetRequiredService<ISystemClock>().UtcNow.TimeOfDay}"),
                new Delay(10.Seconds()),
                new WriteLine(context => $"Finish {context.GetRequiredService<ISystemClock>().UtcNow.TimeOfDay}"),
            }
        };

        builder
            .WithActivationStrategyType<SingletonStrategy>();
    }
}

Expected Behavior

This workflow should print out Start ... then Finish ... in sequence.

Actual Behavior

Every 5 seconds a Start ... and a corresponding Finish ... is printed.

Start 09:13:13.7904393
Start 09:13:18.7184339
Start 09:13:23.7192477
Finish 09:13:23.8538843
Start 09:13:28.7107583
Finish 09:13:28.7340925
Start 09:13:33.7075519
Finish 09:13:33.7464776
Start 09:13:38.7213696
Finish 09:13:38.7266934

Log Output

Include any relevant log output or error messages that might help diagnose the issue.

Troubleshooting Attempts

This does not happen when I trigger the same work from HttpEndpoint trigger.

@wseegersatdealx wseegersatdealx added the bug Something isn't working label Apr 30, 2024
Copy link

glime-ai bot commented Apr 30, 2024

To address the issue you're experiencing with the SingletonStrategy not being respected when using the Timer activity in Elsa, it's important to ensure that the SingletonStrategy is properly configured and that there are no conflicting configurations that might cause the workflow to behave differently than expected.

Based on the information provided, it seems like you have already configured the SingletonStrategy for your workflow. However, the behavior you're observing suggests that new workflow instances are being created every 5 seconds, which is not the expected behavior for a singleton workflow.

Here are a few troubleshooting steps you can take:

  1. Check for Conflicting Configurations: Ensure that there are no other configurations that might be overriding the SingletonStrategy. This includes checking for any other workflow definitions that might be using the same Timer activity with different activation strategies.

  2. Review Elsa Version: Make sure you are using a version of Elsa that supports the SingletonStrategy as expected. If you are using an older version, consider upgrading to the latest stable release.

  3. Review Quartz Configuration: Since you are using Quartz with Elsa, ensure that the Quartz configuration is correct and that it's not causing any unexpected behavior with the scheduling of the Timer activity.

  4. Check for Known Issues: Review the Elsa GitHub issues and discussions to see if there are any known issues related to the SingletonStrategy and Timer activities. It's possible that you might be encountering a bug that has already been reported.

  5. Create a Minimal Reproducible Example: If possible, create a minimal reproducible example that isolates the issue. This can help in identifying whether the problem is with your specific configuration or with Elsa itself.

  6. Seek Support from the Community: If you're unable to resolve the issue on your own, consider reaching out to the Elsa community for support. You can ask questions on the Elsa GitHub repository, Stack Overflow, or the official Elsa Slack channel.

If you have any log output or error messages, please include them as they can provide additional context that might help diagnose the issue.

If you've already tried some of these steps, please let me know which ones and what the outcomes were, so we can further narrow down the problem.

This comment was generated by Glime.

@wseegersatdealx wseegersatdealx changed the title Timer Trigger not respecting SingletoneStrategy [BUG] [BUG] Timer Trigger not respecting SingletoneStrategy Apr 30, 2024
@wseegersatdealx
Copy link
Author

While poking around it seems like IWorkflowActivationStrategy.GetAllowActivationAsync is never reached.

Have I incorrectly configured the workflow?

@m03392
Copy link

m03392 commented May 2, 2024

Same problem for me:

GetAllowActivationAsync() gets never called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants