I got invalid event order which is published by EventBus inside of saga. here’s how it should works.
class GoogleCloudInitializationSaga {
lateinit var eventBus: EventBus
lateinit var commandGateway: CommandGateway
lateinit var cloudServerId: String
@SagaEventHandler(...)
fun on(event: GoogleCloudServerDeviceSetupEvent) {
deviceSetup()
publishProcessingEvent(TaskState.DeviceMapping)
// this will publish GoogleCloudServerLaunchingEvent further
commandGateway.send<>(LaunchGoogleCloudServerCommand(...))
}
fun on(event: GoogleCloudServerLaunchingEvent) {
launchServer()
publishProcessingEvent(TaskState.Launching)
}
// this one just keep track current setup state of a cloud server
private fun publishProcessingEvent(taskState: TaskState) {
eventBus.publish(GenericEventMessage(
GoogleCloudServerProcessingEvent(
cloudServerId = cloudServerId,
taskState = taskState
)
))
}
}
so as you can see it should publish processing event with taskState DeviceMapping first and then publish processing event with taskState Launching and so on, but here’s what I got from event store.
(simplify format from axon server)
{
token: 19129,
payloadData: {
taskState: "Launching"
}
},
{
token: 19133,
payloadData: {
taskState: "DeviceMapping"
}
}
So the event order is invalid, DeviceMapping should come before Lanuching (sometimes it works sometimes it doesn’t). I’m not sure if it related to this issue Not right order of events during read by findTrackedEvents · Issue #1750 · AxonFramework/AxonFramework · GitHub since I’m using axonframework version 4.4.8 Would upgrading newer version solve this issue.