'Which is a better approach to persist the spring state machine context or restore the state machine using the state enum on entity object?

I am new to spring state machine and trying to understand which is a better approach whether to persist the state context in a database or to restore the state machine from the domain object?

I am trying to implement state machine to handle an e-commerce Order fulfillment process. I have come across 2 different approaches to restore the state machine

  1. Persist the state machine context as described here
  2. Restore from the domain object as described here

I am not able to understand the pros and cons of each method and how to determine which is a better approach for processing large number of orders per day.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source