Check if Process/Activity is currently running : Having AT MOST 1 instance running

In our setup, we have a message bus that is sending one of our webhooks events. After our webhook receives the event, it starts up a Process. The events coming in can be rapid or they can be vary infrequent. Right now, a new Process is spun up every time the webhook is hit. Usually this is fine, but sometimes the Process or Activity can still be running when another event comes in, which is a problem for us. 


Instead, what we would like to do is to check if the Process or Activity is already running in a different instance. That way we can ensure that a particular Process or Activity has just one instance running at a time.


Is this possible to accomplish? I don't really see anything obvious in the BPT doc or dependency, but I'm still digging. If it helps any, we're using Reactive Web (I don't think it matters).


If this isn't possible, does anyone have any other suggestions to how we can keep at most 1 instance of a Process or Activity running at a time?

Hi,

There is a table called process where you can check if a particular process is running. Can you explain the use case little better, it looks like you can store the event in a table and start a timer. Timer usually run one instance at a time and in the timer you can process the event and mark it as completed so that next timer reads the event which was not yet picked. Are you using any king of human activity?

Regards.

Hi Joseph,

Only solution I can think of is using Process & Process Definition entity of System espace. You can add depedency of these entities and then you will be able to check if process with same definition is already running. For checking the status you will also need to add depedency of the Process_Status entity which has a foreign key with Status attribute of Process Entity.

Here is more context as to what our setup looks likes. This is still a bit stripped down, so please let me know if there is still additional information needed.


We are using a microservice architecture pattern. We want to keep all of our services and databases as loosely coupled as possible. As a result, we use Azure Service Bus for our services to place events/messages that other services might need or want onto a bus. Since OS can't poll, we have Azure Event Grid on top of the Service Bus to send the events to a webhook (which is just an OS Service module exposed REST API). As soon as the webhook is hit, it starts the associated Process. The Process/Activity is then responsible for sending the event to the appropriate service for processing and removing the message from the bus once completed. 


Event Grid doesn't tell us the specifics of a message, rather it just tells us that at least one message exists on the bus. As a result, we treat Event Grid as an invoker; simply a "ok, we have at least one message. Now go start processing the subscription". The process then handles iterating over the subscription and will continue to process all of the messages on the bus until there are none left. 


Usually, there is just one or two messages on the bus when Event Grid hits our webhook so processing is fast. However, sometimes there are MANY messages available and iterating over the entire subscription can be lengthy. Event Grid will keep on sending the webhook notifications (every 2 minutes) until all of the messages on the subscription are gone. There may be times that another Event Grid webhook call is made while the first process is still running. If we allow that second process to spin up, we can potentially get message contention (out of order, desync, etc). Thus, we want to ensure that a particular process can only be running one at a time.


Looking further in to it, I had the though of just using a new Entity to store actively running processes. Using the OnStart event to write to the Entity and the OnEnd event to delete from the Entity. Then the Process can have a step to check that Entity to see if it already exists (already running) before moving on or ending.