2

This is not an ask for design suggestion :) I am trying to build a workflow engine which can handle manual actions from users. Since Spring-state machine has JPA configurations to build state machine so, I thought I would build multiple flows by providing a machine id, e.g. sql:

(ID, INITIAL_STATE, KIND, MACHINE_ID,STATE)
VALUES
(1, 1, 0, 'M1', 'DOC_PENDING'),
(2, 0, 8, 'M1', 'BANK_DETAILS'),
(3, 0, 8, 'M1', 'DOC_PENDING'),
(4, 0, 1, 'M1', 'CLOSED'),
(5, 1, 0, 'M2', 'DOC_PENDING'),
(6, 0, 8, 'M2', 'BANK_DETAILS'),
(7, 0, 8, 'M2', 'DOC_PENDING'),
(8, 0, 1, 'M2', 'CLOSED')
;

M1 -> is one flow of order and has multiple instances - O1, O2, O3, M2 -> is another flow of payment - O5, O6, O7

That means, my state machine should be able to handle two different order flows and each flow could have multiple people performing their order. e.g. Cashless order and cash orders could be two different flow. Instead of making one giant complicated flow, I want to create two state machines based on the type of order.

Also, I want to reinstantiate a statemachine as in when events arrive to my application. How can I do it? Any code samples would be much appreciated.

Prabhat Ranjan
  • 400
  • 3
  • 17

0 Answers0