Non deterministic finite state machine in java for complex CRM logic

817 views Asked by At

Was looking at implementing Non-deterministic finite state machine in Java. Have checked easyflow and many other such libraries but they offer is Deterministic finite state machine.

Eg. Use case. A user is in suspended state and has bill due of 100$ now he can refill his account with money voucher. if he refills with amount that makes his user balance less than 100 then he will continue in suspended state and if his account balance reached equal or more than hundred dollar then user is send to Active state.

So the event is same "refill" but user states very on his user-balance. So FSM is not deterministic.

Is there any idea on how to cater the case??

On contrary on the second thought I can implement this indeterministic FSM (or kind of FSM) using rule engines like drools .

Oracle BRM seems to be using some sort of state machine. Any idea on how ND-FSM is implemented in crm-systems. And what are the most used library(java) for same.

1

There are 1 answers

8
Pete Kirkham On

Your state machine is not 'non-deterministic', but merely needs either guards on some of the transitions, which reduce to extra transitions in your handler. I don't know the library you're using and it has no documentation so I don't know whether it supports guards, so instead when in the 'refill received' state your handler can check the resultant balance immediately trigger either transition to either 'suspended' or 'active'