State Machine implementation for Spring Boot Project
Nov 10, 2020
What is State Machine
Well I do not write a lot about it. You have plenty of resources to read about it.
The behavior of state machines can be observed in many devices in modern society that perform a predetermined sequence of actions depending on a sequence of events with which they are presented.
Spring Framework’s Implementation
Spring Statemachine is a framework for application developers to use state machine concepts with Spring applications.
Simple Order Management Use case
Lets take below simple example
- Customer Submit an order.
- Customer pay or cancel.
- Order will be fulfilled or cancelled.
How do we map this to Spring State-Machine
We can start Spring boot project using Spring initializer
Make sure to add Spring Statemachine dependency
Maven:
<dependency>
<groupId>org.springframework.statemachine</groupId>
<artifactId>spring-statemachine-core</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>