Questions tagged [spring-statemachine]
Spring Statemachine is a framework for application developers to use state machine concepts with Spring applications.
286
questions
0
votes
0
answers
12
views
How to add a reactive guard to a spring state machine external configuration?
I'm working in a reactive java project with spring state machine version 3.2.1. I have created a reactive guard like this:
public ReactiveGuard<BookingState, BookingEvent> bookingIdGuard(){
...
0
votes
0
answers
14
views
Listen state change in reactive spring state machine
I'm working in a reactive java project with spring state machine version 3.2.1. I need to reactively save and entity every time that the state changes.
Before, when I was using spring state machine 2....
0
votes
0
answers
10
views
persist actions and transitions with EnumStateMachineConfigurerAdapter
How to save Action and transition using spring statemachine 3.2.1 ??
I tried to follow the guides and implement persistence of actions and transitions.
i implemented the StateMachineRuntimePersister ...
0
votes
0
answers
14
views
StateMachine get Object for Test
StateMachineJackson2RepositoryPopulatorFactoryBean get State machine from it.
I am trying to create a entire test case for state machine for that I am trying to generate StateMachine Object from model ...
0
votes
0
answers
23
views
Spring statemachine redis - configure ttl
I'm using spring statemachine in my spring boot application. In this application I have configured redis as StateMachineRuntimePersister in this way:
@Bean
public StateMachineRuntimePersister<?, ?, ...
0
votes
0
answers
22
views
Can Spring State machine support multiple initial States and parallel executions (multi-threaded environment)?
We've recently integrated the Spring State Machine into our workflow. Here's how we're using it: We're receiving events from an SQS queue, and then we're processing these events using the state ...
0
votes
0
answers
14
views
Spring state machine - deferred events are not handled (under load)
We are using Spring State Machine and there are some state that we have defined deferred events for
In normal running of the program everything is OK and the deferred events are activated when the &...
0
votes
0
answers
22
views
How to rollback the state when encountering errors when I hold multiple Spring Statemachine?
I have a problem when using the Spring Statemachine, here is the detail:
I create two different statemachines before. However, they are both need to move forward in one transaction according to a new ...
0
votes
0
answers
34
views
How to create dynamic sub-states in state machine?
I'm new to State machine. Could you explain, it's possible to create dynamic sub-states (pseudo states) in @Configuration classes with application context, or it's possible only by Builder?
For ...
0
votes
0
answers
71
views
Configuration issue with stateMachine and it's version
@Service
public class ClaimService {
@Autowired
ClaimRepository claimRepository;
@Autowired
StateMachineFactory factory;
public boolean selectDate(ClaimRequest claimRequest) {
...
0
votes
0
answers
23
views
How to GET and Persist Action<S,E> from StateMachine?
I have a Spring StateMachine, everything runs smoothly and I am persisting some part of stateMachine Manually (I think Spring StateMachine does not it behind the hood):
var sources = new ...
0
votes
0
answers
80
views
How to automatically persist all Spring StateMachine transactions, actions and so on?
I am using spring statemachine and actually I'm able to persist the state_machine because I'm using the StateMachineRuntimePersister. The problem is when i look to for example the table transition ...
0
votes
0
answers
74
views
Spring state machine - is it thread safe?
This is an example State Machine
(State1)==>(State2)==>(State3)
With event "Event1" that transitions the state machine to State2 and then "Event2" transitions the state ...
0
votes
1
answer
88
views
RedisStateMachinePersister is not persisting StateMachine with Redis
I am using RedisStateMachinePersister for persisting StateMachine with Redis. I can store StateMachine with below code
redisPersister.persist(mc,"1");
redisPersister is instance of ...
0
votes
1
answer
69
views
How to listen to each event that is being sent to spring state machine
I have a use case where i want to listen to each event that is being sent to my spring state machine and log them . Currently I can see spring only supports listening to OnTransitionStartEvent, ...
0
votes
0
answers
23
views
Terminating an application while the Spring state machine is running
The Spring state machine is configured as follows, for example:
A (initial) --> B --> C (choice) --> D/E/F --> G (end)
The states B,D,E,F take a long time to execute.
When the ...
0
votes
0
answers
37
views
How to set Spring StateMachine execute actions on same thread - no spawning of thread?
Looking at the code, seems like Spring SM goes into a "fast" mode, where it spawns a new thread. Does it have an option to go into "slow" mode? The following code is from Spring SM,...
0
votes
0
answers
24
views
Unable to implement choiceGuard() in StateMachineModelFactory using SpringBoot
I want to implement the choice guard to make the State Transition by choice.
It's returning false without stepping into the guard implementation.
It is expected to make the state transition as per the ...
-2
votes
1
answer
209
views
Does Spring Statemachine support Java 17 or above?
Does Spring Statemachine support Java 17 or above?
Their documentation says that the supported version is Java 8. However, the library dependency does seem to compile in a Java 17 environment.
I am ...
0
votes
1
answer
521
views
Reactor and Spring state machine execute Mono then Flux sequentially
I have the following method that is called the method does not have a return value but gets an object from another service metadataService that returns a Mono and then some processing is done with the ...
0
votes
0
answers
48
views
How to move to different state based on guard result
I have a base state that can diverge into two states based on the result of the guard. The guard performs a validation that should determine the next state.
#1: Base State -> (Guard Fails) -> ...
0
votes
0
answers
64
views
Usage of hasPermission with Spring State Machine
I know how to secure a method with hasPermission (ex : @PreAuthorize("hasPermission(#id, 'Review', 'read')").
It seems that Spring State Machine transitions can be secured using Spring ...
0
votes
0
answers
20
views
With spring state machine , can timerOnce be tested
Using spring state machine we have a transition to new state using timerOnce
.source(States.PRE_ACT).target(States.ACT)
.timerOnce(100000)
.action(doSomething)
...
0
votes
0
answers
50
views
String state machine @WithStateMachine where project has 2 state machines
our project has 2 state machines (meaning we have 2 sets of enums for states)
and we want to use @WithStateMachine annotation
we have created this meta annotation below as described in the tutorials ...
1
vote
0
answers
47
views
Using Spring Statemachine we have difficulty changing some statuses
Using Spring Statemachine I encountered a problem when changing the status:
PENDING is the initial status and we have a problem when changing from ARRIVED -> IN_PROGRESS and IN_PROGRESS -> ...
0
votes
0
answers
155
views
Spring State Machine fails to autowire persistence Repositories after upgrading project to Spring 3.0
When creating sample project to learn Spring state machine I stumbled upon an error:
Consider defining a bean of type 'org.springframework.statemachine.data.redis.RedisStateMachineRepository' in your ...
1
vote
0
answers
1k
views
Spring Boot 3.0 Native: Code generation does not support org.springframework.statemachine.config.builders.StateMachineConfigBuilder<?, ?>
Spring Boot 3.0 brings support for native image creation using GraalVM.
I've recently upgraded my project, which implements spring-statemachine-core 3.2.0, to Spring Boot 3.0 and was eager to try out ...
0
votes
0
answers
65
views
Spring State Machine does not maintain order in which actions are triggered when configuration is read from DB
StateMachineFactory is configured to read configuration from db repository. However then statemachine is created, and events are send to machine, the order of actions executed is not maintained. I ...
1
vote
0
answers
83
views
StateMachineInterceptor missed after restoring state machine
I've got problem with my state machine. After rerunnig my service, statemachine that restored is missing StateMachineInterceptor, that I added when was creating the statemachine instance for the first ...
1
vote
0
answers
81
views
Spring State Machine - Persist Libraries and Final State - Stops Listening
I was looking at spring state machine (spending a small amount of time evaluating, before being moved onto another project).
I wanted to use papyrus and UML modeling for an Order Flow. This worked. ...
1
vote
1
answer
145
views
Transition Handlers defined using @OnTransition stop working when statemachine is rehydrated using new StateMachineContext
In the following sample code, I created a state machine and rehydrated it with the state of my choice. However, when I send events, the handlers defined with @OnTransition do not run.
If I comment ...
1
vote
0
answers
69
views
Spring State Machine change DefaultStateContext to custom implementation
I write a simple custom implementation of
public class AdditionalMethodContext<S,E> extends DefaultStateContext<S,E> implements StateContext<S,E>{
public ...
0
votes
1
answer
152
views
Spring stateMachine persistance with Jpa
I got a problem with persister configuration. The problem is similar to Spring State machine - Table Scripts , but I dont want to generate tables by myself or with liquibase. So I'd like to use ...
0
votes
1
answer
346
views
Spring State Machine | Actions (Calling External API with data & pass data to another State)
I would like to use the Action<S,E> to call an external api. How can i add more data into this Action in order to invoke an external API? Another question is what if i want to send back the ...
0
votes
1
answer
510
views
Unable to start spring state machine with spring boot
I am trying to implement Spring state machine with different kind of state and event enums.
public enum OrderState {
ORDER_INITIATED,
ORDER_CONFIRMED,
ORDER_CANCELLED,
}
//Order Events
...
0
votes
1
answer
764
views
Restore Spring State Machine from Database
I have been following the data persist examples outlined in the spring docs
When I acquire a state machine it doesn't pull it from the database but checks in memory. I see records being written but I ...
0
votes
1
answer
1k
views
Spring statemachine how to persist a machine with nested regions
I have statemachine with configuration mentioned at the end, which i want to persist in the database. I am following this tutorial https://docs.spring.io/spring-statemachine/docs/3.1.0/reference/#...
2
votes
2
answers
2k
views
Spring Statemachine State Actions vs Transition actions
Spring statemachine provides following type of actions. Can someone please explain me which type of action should be used in which scenario? And, If an action fails then does statemachine move to next ...
0
votes
1
answer
413
views
How to add spring state machine listener on entity creation?
I have working state machine transition listeners configured: an action is invoked when entity's state changes from A to B. Now I need to invoke an action when entity is created with initial state A. ...
0
votes
1
answer
284
views
Spring statemachine's java configuration for order shipping example
Looking at the following example provided by spring statemachine documentation, it is loading the configuration from a UML file. Unfortunately, i am not familiar with UML so is there any link where ...
2
votes
1
answer
495
views
Spring State Machine use StateMachineTestPlan to test a withChoice transition
If I have a StateMachine set up as below:
transitionConfigurer
.withExternal()
.source(FIRST)
.event(EVENT_1)
.target(SECOND)
.and()
.withChoice()
.source(SECOND)
.first(THIRD, ...
2
votes
0
answers
259
views
Increase thread pool size in Spring StateMachine 3.0.1
We upgraded from Spring Statemachine 2.5.0 to Spring StateMachine 3.0.1 in our project. Our application run a series of processes, each process runs through its business logic within its own state ...
2
votes
2
answers
749
views
How to get the current substate and the parent state out of the Spring Statemachine?
I am running a hierachical Spring Statemachine and - after walking through the inital transitions into state UP with the default substate STOPPED - want to use statemachine.getState(). Trouble is, it ...
0
votes
1
answer
1k
views
Spring Statemachine: how to handle two transitions that has the same source state?
How does Spring Statemachine handle two transitions that has the same source state?
For example:
Source State: ready
Event: start
One transition will be lead to the target state running, another one ...
1
vote
1
answer
375
views
How can I reset state machine to sub state machine?
Can you help me with this please?
I have states for employee { Start, S1 , S1_1_start, S1_1_end , S1_2_start, S1_2_end, S2, End }.
public void configure(StateMachineStateConfigurer<EmployeeStates, ...
1
vote
1
answer
166
views
After working with spring state machine breaks spring auto entity scan mecanism
After i added dependencies of spring state machine my entities seen as not managed type. After adding @EntityScan annotation and tell Spring where to find entities used in our application, spring ...
1
vote
3
answers
940
views
Correct way to use substatemachine in spring-statemachine
I'm not sure I clearly understand how to use substates.
I didn't find any good explained example of correct spring state machine configuration, so I would be glad if somebody can share it we me.
On ...
1
vote
0
answers
497
views
Deferred Event in Spring State Machine
I have been trying to implement the below State machine using the spring-state machine.
Please find the configurations below.
I have been using spring-state machine for one of my project.
public ...
0
votes
1
answer
516
views
Migrating spring-statemachine factory to reactive webflux
I am trying to migrate my app that uses the spring statemachine to use webflux. I was using
private final StateMachineFactory<State, Event> stateMachineFactory;
[...]
StateMachine<State,...
0
votes
1
answer
1k
views
Spring State Machine - Change state based on conditions
I am trying to create a simple state machine as shown below
For this I have below config
@Override
public void configure(final StateMachineStateConfigurer<States, Events> states) throws ...