I’m working with workflows that create an aws cluster then run calculations on it then terminate the cluster. The cluster creation mechanism works with a pool of available clusters (prepared in advanced). Either there is a cluster in the pool and the process will use it for the calculation (and of course flag it as no more available) or the pool is empty and the process will create a new cluster on the fly wait for it to be ready then run the calculations on it. I’m using java delegates to make call to aws api to manipulate the clusters.
My question is how can I ensure that multiple instances of my workflow wont call the same delegate at the same time ? For example let’s say the pool contains only 1 available cluster but 2 instances start at the same time.What I want is that one instance get the cluster and the other creates a new one. What I absolutely dont want is that both instances get the same cluster. Is there a way to deal with that at the bpmn level or at the java delegate level using some kind of mutex ?