cancel
Showing results for 
Search instead for 
Did you mean: 

Count Number of Active Sessions

jgregor4
Level 6
I have multiple resources running the same process and want to be able to use a decision in the process depending on the number of active sessions. Is there a way (maybe through custom code) to count how many sessions of a particular process are running in the control room? This way I can use a decision on the number to send the process flow down a different route depending on the number.
3 REPLIES 3

John__Carter
Staff
Staff
I'm afraid there is no easy option. In theory you could just query the DB, but that would break your security model. You could make the process record its presence by adding an item to a queue and then locking it. If the process failed, the item would get the exception 'Automatically set at cleanup', if the process completes, then it can just mark the item as complete. To answer the 'how many of me are there?' the process could count the number of locked items. To avoid the chance that the count is made at the exact moment between adding and locking an item, you could use an environment lock to ensure 'one at a time' access to the queue. I totally accept this is way too much work for something that should be easy!

jgregor4
Level 6
I have spoken to a colleague and decided that we will create an Excel file at the start of the process - when it gets to the point when we need to know the number of sessions running a count will be taken of the files in a folder to determine the number. As each session ends the file will be deleted.

John__Carter
Staff
Staff
Yes that could work. Just consider the possibility of process terminating and mot getting chance to delete the file. That's why I suggested a queue item, because it will automatically be marked as an exception.