EventHandler not getting triggered

I have an Aggregate class that has
i) 1 CommandHandler that receives a CreateAccountCommand
ii) 1 EventSourceHandling that receives AccountCreatedEvent

Correspondingly, in another package, I’ve @EventHandler for the AccountCreatedEvent. However, it is not getting invoked. I’m using spring boot application.

@Component
class EventHandlingComponent {

@Autowired AccountRepository repo; 

@EventHandler
public void on(AccountCreatedEvent event ) 
{
// save to repository ; 
}
}

I’m using spring boot application with this added as a dependency.

	<dependency>
			  <groupId>org.axonframework</groupId>
			  <artifactId>axon-spring-boot-starter</artifactId>
			  <version>4.5.3</version>
		
			<exclusions>
				<exclusion>
					<groupId>org.axonframework</groupId>
					<artifactId>axon-server-connector</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

I’ll be really thankful if someone can point me to what mistake I’m making.

Hi @Gks_96,

I see you asked the same question on stackoverflow.

Looking at the questions and responses there, the easiest way to help you would be to have a simple project where you see this behavious. So, in short, a github project where we can check what you are doing and help you.

KR,

Hi @lfgcampos thanks for replying.

Here is a demo project repo.
But in my main project (whose code I can’t share), the @EventHandler is not getting called. I was looking for possible reasons for the same. I’m not even creating a separate class for it. In the service layer, I have a method annotatetd with @EventHandler. The other function in the service layer gets invoked, therefore the component is registered with the Spring Framework. Can you suggest any other thing which I can cross check?

Thanks for your patience and sorry for the late reply.