spring-projects / spring-statemachine

Spring Statemachine is a framework for application developers to use state machine concepts with Spring.
1.52k stars 598 forks source link

Reactive persistence API #1070

Open smaugfm opened 1 year ago

smaugfm commented 1 year ago

I see that components & APIs responsible for persistence do not provide a reactive interface. This is weird since the library recently switched to the all-reactive interface for the state machine operation.

I looked through the code of DefaultStateMachinePersister, MongoDbPersistingStateMachineInterceptor etc. and it seems fairly easy to create reactive counterparts of all those components & interfaces. Which I already have done successfully while working on my project:) But only for MongoDB and only the parts we need.

There already exist reactive APIs in Spring for JPA, MongoDB, and Redis. The question I have is would it be OK if I contribute the reactive API for the whole persistence code currently present in the library?

siaavush commented 1 year ago

I have a similar issue with DefaultStateMachinePersister for calling acquireStateMachine(machined) and I am getting this exception:

Caused by: java.lang.IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-nio-3
    at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:83) ~[reactor-core-3.4.23.jar:3.4.23]
    at reactor.core.publisher.Mono.block(Mono.java:1707) ~[reactor-core-3.4.23.jar:3.4.23]
    at org.springframework.statemachine.service.DefaultStateMachineService.restoreStateMachine(DefaultStateMachineService.java:167) ~[spring-statemachine-core-3.2.0.jar:3.2.0]
    at org.springframework.statemachine.service.DefaultStateMachineService.acquireStateMachine(DefaultStateMachineService.java:95) ~[spring-statemachine-core-3.2.0.jar:3.2.0]
    at org.springframework.statemachine.service.DefaultStateMachineService.acquireStateMachine(DefaultStateMachineService.java:79) ~[spring-statemachine-core-3.2.0.jar:3.2.0]

Is there an alternative or workaround for this?

sheinbergon commented 1 year ago

+1. It's kind of odd this issue has been "left behind"