I am trying to register Event handler interceptor provided as in Axon documentation but my Tests are failing because its not able to create the Bean

I am using following method from Axon documentation, to intercept Events:

public void configureEventProcessing(Configurer configurer) {
configuration → new TelemetryEventHandlerInterceptor());

But its throwing exceptions in my unit test:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘org.axonframework.config.Configurer’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

I tried mocking it my unit test but not successful. Has anyone faced this issue? any workarounds?

Maybe try to put the EventProcessingConfigurer processingConfigurer as the argument you are autowiring instead of the Configurer? You can then configure it like you are doing anyway.

Or try to put the @Autowired block into a @TestConfiguration class which is loaded as part of the @SpringBootTest.

1 Like

This solution isn’t working for me.
public void configure(EventProcessingConfigurer configurer){
configurer.registerListenerInvocationErrorHandler(“sample”, config → new MyServiceEventsErrorHandler);

I am getting the same error, required a bean of type ‘org.axonframework.config.EventProcessingConfigurer’ that could not be found.