Dhaval Goti
Dhaval Goti

Reputation: 457

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 RedisStateMachinePersister. I can also see in Redis termianl that some value is stored in Redis with key "1".

enter image description here

But when I try to retrieve this StateMachine with same key("1") with below code, it is not getting retrieve the StateMachine object which I have stored/persisted.

redisPersister.restore(mc2,"1");

mc2 object is not same mc object which I have persisted/stored.Any help on this would be appreciated.

Upvotes: 0

Views: 364

Answers (1)

BendaThierry.com
BendaThierry.com

Reputation: 2110

Following the instructions from the official documentation, you will get the job done :

  1. https://docs.spring.io/spring-statemachine/docs/1.1.x/reference/html/sm-persist.html
  2. https://docs.spring.io/spring-statemachine/docs/1.1.x/reference/html/statemachine-examples-eventservice.html

Edit 2023/05/14 : It seems really strange you didn't get back the record you have stored here. Some legit questions to check while thinking about your problem context :

  1. Do you have multiple REDIS servers installed listening on various ports (with system packages managers and with docker too) ?
  2. Do you have checked your Spring datasource configuration for REDIS ?
  3. Do you use spring profiles to handle your dev/test/prod databases and your accordingly cache configs ?

Edit 2023/05/16 : Try to use any java client as jedis or lettuce to query datas from redis. It seems reading directly in-memory datas directly is not possible without using a java client, not as standard RDBMS which are allowing that

Upvotes: 0

Related Questions