We have multiple automation scripts (SRM Profile Load Scripts) that are trying to set the same parameters on the same element at the same time which causes troubles.
Currently we're using this as locking mechanism:
private static ConcurrentDictionary<string, object> lockDictionary = new ConcurrentDictionary<string, object>();
var lockObject = lockDictionary.GetOrAdd(mainElementId, (key) => new object());
lock (lockObject)
{
//do your sets
}
However this only works within the same SLAutomation process => if the scripts are running from the same DMA. In case of a cluster environment, how can I make sure that profile load scripts that are running on different DMAs are waiting for each other before making sets to the element?
Hi Jochen,
I guess you can resolve this by using Mutex for your locking.
Hi Tom, I wasn’t aware of that. Is there something else that can be used instead?
Not out of the box. For locking that works over multiple machines, something that manages those locks will be needed (i.e. database, element, …). Clients connect to that manager to acquire and release the lock.
Hi Jens. A mutex can be used for inter-process communication on the same machine. This doesn’t work when the processes are running on different machines as in this case.