infinitic icon indicating copy to clipboard operation
infinitic copied to clipboard

Singleton Service

Open gmendoza-wenance opened this issue 3 years ago • 1 comments

Hi! I need to know if it's possible execute a Workflow as a Singleton. I mean: I need the execution of only one workflow at any time.

behavior expected: when I call multiple dispatch calls, only execute the one, the others must die or throw a runtime error.

Screenshot from 2022-08-11 11-08-15

If this is not possible, ¿May I implement another strategy? Maybe checkout if Infinitic is already running a SingletonWorkflow.class?

Thanks in advance

gmendoza-wenance avatar Aug 11 '22 14:08 gmendoza-wenance

Maybe something like this helps

if (client.getRunningWorkflows().contains("singleton-workflow-id")) {
    System.out.println("Please wait...the singleton is working yet");
}

gmendoza-wenance avatar Aug 11 '22 14:08 gmendoza-wenance

Hello, I think you can achieve that with unique-tag. https://infinitic.substack.com/i/52382438/unique-tag The feature isn't documented well at the moment but it works well. Regards

Ouriel avatar Sep 07 '22 14:09 Ouriel

Thanks Ouriel! It's correct, Gilles Barbier answered the the same in his Medium personal page. Regards!

gmendoza-wenance avatar Sep 07 '22 14:09 gmendoza-wenance