My application expects a related group of events. I would like to construct a workflow that waits for all the events from the group to arrive (or times out), and then proceeds. Each group and each event have a UID associated with it. The events arrive at random times, and are unknown to my application until they arrive. Each event in a group has a specific, unique type that are known to the application, and each event has a the UID of the group it belongs to.
My first thought was
- when an event arrives, check to see if a workflow for the group has been started
- if not, start the "group" workflow
- send a message to the "group" workflow that this event has arrived
- when all the expected event messages arrive in the "group" workflow, proceed with processing the entire group
My concern is that the timing of events is random, and I may start 2 "group" workflows for the same group and process each group twice, or, worse, they may starve waiting for the correct messages. Aside from using Java to synchronize the "group" start, is there a standard way to do this within Activiti?