Schedule Task Over Cluster

Hi Team ,

Currently we have cluster with two nodes , that we are running our application as uberJar
How to prevent both nodes for calling same function twice to prevent duplicate code execution

Function is for sending mails each period of time

Defined As below

image

The business behind is that , we are selecting all mails that scheduled to be sent from DB then we start sending them if both nodes are running then same query will be executed on both nodes and same logic will be also executed and mail will be sent twice

I was thinking about select for update to lock record on DB but actually i don’t know if you have better way to configure one node to be running the scheduler ?

looking your guidance

Thanks

There is a singleton checkbox on your screenshot.

See also: Task Registration - CUBA Platform. Developer’s Manual

Singleton – indicates that the task is a singleton, i.e. should be run only on one application server.

1 Like