State Machine implementation for Spring Boot Project

Ishan Liyanage
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

  1. Customer Submit an order.
  2. Customer pay or cancel.
  3. 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>

--

--

Ishan Liyanage
Ishan Liyanage

Written by Ishan Liyanage

Passionate Technical Lead, Senior Software Developer and free and open source software advocate. Based in Singapore.

No responses yet