java - Axon is unable to resolve the Event in the EventHandler - Stack Overflow

[13:26:44 WARN] [.axonframework.config.DefaultConfigurer]: One of the start handlers in phase [-2147483

[13:26:44 WARN] [.axonframework.config.DefaultConfigurer]: One of the start handlers in phase [-2147483648] failed with the following exception: 
2025-03-22 14:26:44 java.util.concurrent.ExecutionException: .axonframework.messaging.annotation.UnsupportedHandlerException: Unable to resolve parameter 0 (AgentCreatedEvent) in handler public void a.b.c.listener.AgentListener.on(a.b.c.messages.events.agents.AgentCreatedEvent)

I have the following setup:

  • A Spring Boot instance that publishes events and holds the Aggregates

  • A non-spring-boot app that uses Kafka and PostgreSQL instead of the AxonServer

When I tried running my non-spring app with AxonServer the same error occured. The `a.b.c.messages` package is shared between the spring and non-spring app.

The spring-boot app is unaffected and works flawlessly. But the non-spring app fails at startup.

I'm using this to register my EventHandler:

@Override
public void registerEventHandler(Object eventHandler) {
  configurer.registerEventHandler(conf -> eventHandler);
}

And after that I start the application, once all my EventHandlers are registered. I'm using the DefaultConfigurer with the JacksonSerializer provided everywhere

I tried looking into the documentation and searching for similar issues but the ones I found seemed to have been left unanswered and I couldn't find more information to my issue in the documentation.

The only thing I found, is .11/messaging-concepts/supported-parameters-annotated-handlers/ which I follow:

import a.b.c.messages.events.agents.AgentCreatedEvent

...

@EventHandler
public void on(AgentCreatedEvent event) {
  agentService.addAgent(event.getAgent());
}

I'd appreciate help on finding out why this error occurs on startup and what causes it so that I can run Axon normally again

[13:26:44 WARN] [.axonframework.config.DefaultConfigurer]: One of the start handlers in phase [-2147483648] failed with the following exception: 
2025-03-22 14:26:44 java.util.concurrent.ExecutionException: .axonframework.messaging.annotation.UnsupportedHandlerException: Unable to resolve parameter 0 (AgentCreatedEvent) in handler public void a.b.c.listener.AgentListener.on(a.b.c.messages.events.agents.AgentCreatedEvent)

I have the following setup:

  • A Spring Boot instance that publishes events and holds the Aggregates

  • A non-spring-boot app that uses Kafka and PostgreSQL instead of the AxonServer

When I tried running my non-spring app with AxonServer the same error occured. The `a.b.c.messages` package is shared between the spring and non-spring app.

The spring-boot app is unaffected and works flawlessly. But the non-spring app fails at startup.

I'm using this to register my EventHandler:

@Override
public void registerEventHandler(Object eventHandler) {
  configurer.registerEventHandler(conf -> eventHandler);
}

And after that I start the application, once all my EventHandlers are registered. I'm using the DefaultConfigurer with the JacksonSerializer provided everywhere

I tried looking into the documentation and searching for similar issues but the ones I found seemed to have been left unanswered and I couldn't find more information to my issue in the documentation.

The only thing I found, is https://docs.axoniq.io/axon-framework-reference/4.11/messaging-concepts/supported-parameters-annotated-handlers/ which I follow:

import a.b.c.messages.events.agents.AgentCreatedEvent

...

@EventHandler
public void on(AgentCreatedEvent event) {
  agentService.addAgent(event.getAgent());
}

I'd appreciate help on finding out why this error occurs on startup and what causes it so that I can run Axon normally again

Share Improve this question asked Mar 22 at 14:12 CronixZeroCronixZero 351 silver badge5 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

The Axon Framework 4 Configuration API, although useable outside of Spring contexts, isn't ideal. This is, in part, why we're doing a massive rewrite of the Configuration API for Axon Framework 5. However, that's not helping you at the moment, @ChronisZero.

Although I need to guess why this is happening, I think it has to do with Axon Framework's lifecycle management. The Configurer is a place where components, and lifecycle handlers are registered to.
If you have started (through Configurer#start) the configure and after that try to register event handlers, you've already opened up the buses to interact with your application.

Hence, if this non-Spring application has Kafka as a message source, you start the Configurer, and only after that register the event handler, the message source will already try to find handlers for the given event.

Now, to circle back, I am not 100% sure whether this is the case, as you haven't shared how you are configuring the rest of your Axon Framework application. Thus, if my assumption is incorrect, I would recommend that you update your question with more information on how you're using Axon Framework's Configuration API at the moment.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744312145a4568001.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信