TrackingProcessor in Spring Boot is not executed

Hello everyone,
I have a (hopefully simple) question about Spring Boot and Tracking Processors in Axon.

I am using Axon 3.1.2 in combination with Spring Boot.

I have a simple demo app in which I want to replay events from a JpaEventStore:


@Bean

public EventStore eventStore(EntityManagerProvider provider, TransactionManager transactionManager) {

    return new EmbeddedEventStore(new JpaEventStorageEngine(provider, transactionManager));

}

I have the following configuration for the evendHandlingConfiguration:


@Configuration

public class AxonConfig {

    @Autowired

    public void configureProcessors(EventHandlingConfiguration eventHandlingConfiguration) {

        eventHandlingConfiguration.registerTrackingProcessor("emp");

    }

}

When I have a ProcessingGroup annotation set, there is no action at all from the framework.


@ProcessingGroup("emp")

public class EmployeeTest {

    @EventHandler

    public void on(EmployeeCreatedEvent evt) {

        System.out.println("EmployeeCreated");

    }

}

In another part of the app there are some events created which I can see in my underlying MySQL database.

Also the TokenStore tables are automatically created:

In my application.properties have I set the following line:

axon.eventhandling.processors.emp.mode=tracking

After all of this…no action for replaying. What am I forgetting?!?

I hope someone can point me in the right direction.

Thanks in advance.
Martijn de la Cosine

Hi Martijn,

how did you register the EmployeeTest class in the application context? There isn’t any @Component annotation on it.

Also, setting the “mode” property for the processor in your application.properties file makes the Java version of registering it as a tracking processor obsolete. Lastly, you don’t need to define the EventStore bean in your context. If you have JPA active in your application context, you get the JPA based EventStore “for free”.

Hope this helps.
Cheers,

Allard

Hi Allard,

Thanks for the quick reply and if you, like me, living in the Netherlands outside the office hours!

I made several mistakes in my code. The first one is that I indeed forgot the @Component in my EmployeeTest. This was a side effect about copy and pasting from my Employee class with a lot of code that did not had to do anything with my issue. So I added @Component and it works…but I saw that my Employee class had a @Component and a @ProcessingGroup and still didn’t work.

This is by testing a result of the @Aggregate annotation. I am new in the CQRS style of programming and I mixed things up. My Employee class is an aggregate and I want it to participate in the tracking processing group. This is not gonna work and I think that I understand why, separation of model and query.

Is this the right conclusion?

Again thanks!!

Cheers,
Martijn

Hi Martijn,

your Aggregate is part of the Command Model. Processors (Tracking or Subscribing) are components used in Event Handling, which is used (among some other things) to update the query models. That’s why you can’t (and don’t have to) assign Aggregates to Processors. The Events handled by an Aggregate are only its own, in case you use Event Sourcing. They will never receive events from other components.

Hope this clarifies it.
Cheers,

Allard