Division of State Machine

The SCXML is divided into the following parts:

  • Order SCXML: Manages events related to Order, OrderLine, Plan, and Order Amendment.

  • Plan Item SCXML: Manages events for individual plan items, with each plan item having its own SCXML stored in the plan_item_data table.

The order events are processed in the following sequence:

  1. Determines if the event is for the order, order line, plan, amendment, or for a specific plan item.

  2. Fetches the required SCXML from the database.

  3. Unmarshals the XML to a StateMachine object.

  4. Fires the order event.

  5. Marshalls the latest snapshot of the StateMachine to XML.

  6. Saves this XML back to the database.

By dividing the SCXML into smaller segments, the process of marshaling and unmarshalling becomes more efficient, leading to reduced processing time.