Axon startup app - Sending all events from eventstore (mongo) to eventbus (kafka)

Hi,

I’ve two Axon 4.3.1 application. One to Command using mongoDB (command model) and another using postgres to projection views (query model).

Both applications are using SubscribingEventProcessor, to produce and to consume events to and from kafka.

The problem is: Command model application is always (on startup) sending ALL events from mongodb (eventstore) to eventbus (kafka), again and again to projection. Important: if I’ve JPA in pom dependencies (and config in bootstrap.yml, as spring.datasource.url) the events are not sent from mongo to kafka.

I don’t know if this’s correct. (performance problems)

Can you help me?

Hi Marcelo,

The problem could be that you are using an in-memory token store, so every time application starts up all events are dispatched because the tracking processor always is initialized with a null token.

I fixed that problem configuring a postgresql as token store.

https://docs.axoniq.io/reference-guide/configuring-infrastructure-components/event-processing/event-processors#token-store

Regards,
Rodrigo Castilho

Hi Rodrigo,

Thank you for your fast reply.

Your tip worked. Now, I setup the MongoTokenStore to command application, like so:

@Bean
public TokenStore tokenStore(Serializer serializer, MongoClient client) {
return new MongoTokenStore.Builder().mongoTemplate(
DefaultMongoTemplate
.builder()
.mongoDatabase(client, “mongo-event-store”)
.build()
).serializer(serializer).build();
}

Using SubscribingEventProcessor type I thought that no need tokenStore (of course, InMemoryToken store as default config was the problem).

I’d like to know if this’s the correct way to acomplish that.

Thank you,

Marcelo

Hi Marcelo,

The only situation where adding the TokenStore would resolve this problem is if you have a TrackingEventProcessor publishing the events on Kafka.
Take a look at the reference guide on the matter, maybe you’ve missed configuring event publication to Kafka to use a SubscribingEventProcessor?

Cheers,
Steven