The JMS event gateway persists the events in persistent store when it receives them. Each event is stored in the order in which it is received. The events received may not be in the order in which they are generated in external system due to issues like network latency. Therefore, events cannot be processed sequentially based on the order in which they are stored in persistent store. BP Server Event Processing Scheduler (the scheduler) processes the external events. The scheduler processes events, marks events ready for processing, and moves processed events to history. Scheduler processes the event and marks it processed in a single transaction. After that, it periodically moves the events marked as processed into the audit or history table.
The scheduler processes the external events as per the process flow. While processing events, if there are any out-of-sequence external events, then it parks them separately, and processes them later when it reaches their corresponding workstep.
The scheduler periodically checks the parked and yet to be processed events, and selects a batch of eligible (events marked as ready for processing) external events that can be processed. The scheduler selects a batch of external events in the order in which they are created in the external system (that is, sorted by the event creation time), and processes them sequentially.
Lifecycle of a typical external event has the following stages.
1. When the JMS messaging gateway receives an external event, it tries to process the event directly.
2. If the gateway could not process the event, then it persists that event in the external events table.
3. The scheduler picks up the events persisted in the external events table, and processes them.
4. When the process flow reaches a monitoring workstep, BP Server moves the monitoring workstep in Monitoring Wait state, and checks if there are any external events associated with the current workstep, that are to be processed.
5. BP Server processes these external events.
6. If BP Server is configured to store the external events to the history table after processing them, then BP Server marks the processed events as processed in the external events table. A scheduler moves these marked events to the history table in bulk. If BP Server is not configured to store the external events to the history table after processing them, then it deletes these marked events after processing them.