What I am trying to accomplish is to limit the rate that an activity is executed in a process. One particular activity I want to only be executed once every 30 seconds.
So what I have done is add a signal catching event before the activity so all instances will wait on a signal. I then have a separate process that is kicked off by a 30 second repeating timer that invoke s a delegate that queries for all executions waiting for the signal, chooses one of them, and sends the signal to just that execution.
That is all working, but I am open to suggestions for better ways to accomplish this.
The problem is that if that activity has an error I route that execution back to waiting on the signal again to retry again later. However that execution that had the error is chosen again by the query soon after it failed. I would rather have that one move to the back of the line.
So my thought was to choose which execution to signal by ordering the query by which one has been waiting the longest, but I can’t find any way to do that or even a way to query when an execution was last suspended.
I know I could probably set some variable on the execution (e.g. a count of errors) and order by that but trying to avoid the extra steps.