I need to create StateMachine to manage quests. I know how to create a state machine, but I can not use it. It's my first state machine and first project with the MongoDB.
My state machine:
@Configuration
@EnableStateMachine
class QuestStateMachineConfig : EnumStateMachineConfigurerAdapter<QuestState, QuestEvent>() {
@Throws(Exception::class)
override fun configure(states: StateMachineStateConfigurer<QuestState, QuestEvent>) {
states.withStates()
.initial(QuestState.AWAITING)
.state(QuestState.ASSIGNED)
.state(QuestState.MARKED_TO_REJECT)
.state(QuestState.IN_PROGRESS)
.end(QuestState.DONE)
.end(QuestState.REJECTED)
}
@Throws(Exception::class)
override fun configure(transitions: StateMachineTransitionConfigurer<QuestState, QuestEvent>) {
transitions.withExternal()
.source(QuestState.AWAITING).target(QuestState.ASSIGNED).event(QuestEvent.ASSIGN)
.and()
...
}
I need to create a quest with state AWAITING, next I have to modify and save it in a database when a user uses update action. How to do it? And how can I listen to onSuccess callback of this operation?