spring-statemachine icon indicating copy to clipboard operation
spring-statemachine copied to clipboard

Reactive persistence API

Open smaugfm opened this issue 3 years ago • 2 comments

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?

smaugfm avatar Sep 19 '22 17:09 smaugfm

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?

siaavush avatar Oct 03 '22 11:10 siaavush

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

sheinbergon avatar Jan 05 '23 16:01 sheinbergon