I am again having some very strange behavior. I am using Spring Boot, Flyway for database migration, Axon Server(Docker) and Kotlin.
Currently the when I publish on the eventBus I get no log messages and the EventHandler is not entered. However after I shut down my program in intellj, delete token_entry table from postgres, restart my program in intellj (Flyway auto generates the table again), then all the EventHandlers are called from the previous run? This is very strange to me…
Lastly, EventSourcingHandler and EventHandlers seem to be working fine when using the CommandHandler and AggregateLifecycle.apply(event)
Here is my code / config :
<dependency>
<groupId>org.axonframework</groupId>
<artifactId>axon-spring-boot-starter</artifactId>
<version>4.4.2</version>
</dependency>
@PostMapping
@RequestMapping("/testEb")
fun testEB() {
eb.publish(GenericEventMessage.asEventMessage<CreateContractEvent>(CreateContractCommand(
contractId = UUID.randomUUID().toString()
)))
}
@EventHandler
fun handle(createContractEvent: CreateContractEvent) {
print("\ninside Event Handler")
}
}
@Configuration
class AxonConfig {
@Autowired
lateinit var transactionManager: PlatformTransactionManager
@Bean
fun eventScheduler(eventBus: EventBus): SimpleEventScheduler {
return SimpleEventScheduler.builder()
.eventBus(eventBus)
.scheduledExecutorService(Executors.newSingleThreadScheduledExecutor())
.build()
}
}