Multiply Triggered Rule

If there were more than five of these events at the same time I’m not surprised.

Unfortunately, I think the answer may reside in the “Rule Logic”.

The first thing is to doubly make sure that you really do need the lock. There is more than one way to deal with the IllegalStateException when events are coming in on a Group while the Rule is actively running.

Without the code it is hard to provide concrete advice but in general:

  • Why does the Rule take long enough to run that this is routinely a problem? Is there a way you can farm some of this long running code into a Timer?

  • Are you iterating over the members of gReachable? Most likely the answer is “yes” and that is what is generating the error. Can you rework your approach to avoid that and just work with triggeringItem?

  • Create a Timer and don’t process the members of gReachable or whatever you are doing to generate the exception until the Rule has been quiet for a second. This may or may not help depending on how regularly the events come in.

  • Get rid of the cron trigger for now. That seems like it will just increase the likelihood of collisions.

  • If you do need to lock, only lock the bare minimum lines of code, not the whole Rule. Make sure that minimum set of code does not and can not generate any Exceptions, particularly type exceptions.

  • Use something like Design Pattern: Gate Keeper to queue up the events and let a Timer work them off in a separate thread. This would work best if you only need information from triggeringItem.