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
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