Order Shipping is an example how state machine concepts can be used with a process of building a simple order processing system.
Below you can see a statechart driving this order shipping sample.
What is happening a above statechart:
WAIT_NEW_ORDER
default state.
PLACE_ORDER
transitions into state RECEIVE_ORDER
and entry
action entryReceiveOrder
is executed.
CUSTOMER_ERROR
final state.
RECEIVE_PAYMENT
is sent successfully to indicate correct
payment.
WAIT_PRODUCT
and
WAIT_ORDER
to be joined before parent orthogonal state
HANDLE_ORDER
is exited.
SHIP_ORDER
into its final state
ORDER_SHIPPED
.
Let’s get into actual demo. Run the boot based sample application:
# java -jar spring-statemachine-samples-ordershipping-1.2.8.RC4.jar
In a browser you see something shown above. You can start by choosing customer and order and create a machine.
Machine for particular order is now created and you can start to play with placing an order and sending a payment. Other settings like makeProdPlan, produce and payment allows you to control how machine works.
Finally you can see what machine does by refreshing a page.