use PerformanceMonitorInterceptor from Spring with Axon


I try to use PerformanceMonitorInterceptor as exampled here: but when I allow its pointcut to check all packages (including @Aggregate and all Axon classes) I get:

Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
16291 [main] ERROR o.s.boot.SpringApplication - Application run failed
java.lang.IllegalStateException: Failed to execute ApplicationRunner
at org.springframework.boot.SpringApplication.callRunner(
at org.springframework.boot.SpringApplication.callRunners(
at com.test.Application.main(
Caused by: org.axonframework.eventsourcing.IncompatibleAggregateException: Aggregate identifier must be non-null after applying an event. Make sure the aggregate identifier is initialized at the latest when handling the creation event.

during application start. I’m not sure what is the reason. Did anyone had such issue?


the underlying issue is that this interceptor creates proxies of beans. Axon isn’t aware that some classes may be proxies, and uses field inspection to get certain values. In proxies, these are all null, because all the proxy does is relay method invocations; it doesn’t keep state.

You can use Message Handler Interceptors in Axon to achieve the same thing. There is an Axon-micrometer module that gives you a lot of metrics out of the box. When using Spring Boot, adding the dependency should be enough.

Hope this clarifies it.