How to use tokenstore with JPA on commandside and queryside?


I’m trying to use JPA with TokenStore on the command side in order to test reply events. But my table token_entry is always empty.

I’m using spring-boot and axon 3.3. What kind of configuration do I have to do in order to have it working on the commandside and the query side?


Any help?

I tried to use this:

public JpaTokenStore tokenStore(Serializer serializer, EntityManagerProvider entityManagerProvider) {
return new JpaTokenStore(entityManagerProvider, serializer);


But I can’t see any message on sprint-boot log and my entry_table always empty.

Any help?

Hi, Here is my configuration for JPA Token Store in Postgres:

public TokenStore jdbcTokenStore(DataSource dataSource, Serializer serializer)
    JdbcTokenStore tokenStore = new JdbcTokenStore(
           new SpringDataSourceConnectionProvider(dataSource), serializer);

     tokenStore.createSchema(new PostgresTokenTableFactory());

    return tokenStore;

Make sure you have configured correctly your datasource through spring.


I tried it but nothing happens. My entry_table is still empty. In log files during the web server start I can’t see any mention to token fetch. Should I put it on command side, right? Any advice?

I suppose you have a database on the query side, and you want to replay events so that the database of your query side gets updated. The tracking processor will do this job, using a token (stored in the tokenStore) , in which token the processor will store its “progress”. All this happens within a context of one service(in your case the query side). What you do in command side, and how you populate your event store etc, is irrelevant to the query side.
The query side service has to have configuration for connection to the event Store, for the tracking processor, and for the token Store.
So in short, you need to have in the query side service, the same configuration you have for the command side service, regarding the event store , plus the configuration for the tokenStore and the tracking processor.

Στις Τετ, 12 Σεπ 2018 - 21:44 ο χρήστης Gustavo Monti <> έγραψε:

Hi Vasilis,

Thanks for your awnser. I did what you said but not working yet. :frowning: I started command and query side with differents dbs and on query side I didn’t see any mention to token and my table (token_store) is always empty even I got events.

I’m having trouble to configure postgres as a token store to test replying events.

Well, in that case it would be helpful if you could give us the source code for the query side axon configuration as well as the query side application properties about your event store, the postgres DB and the axon tracking processor.

I attached the files.

Can you see?

application.yml (454 Bytes) (2.92 KB)

  1. you are missing configuration for a tracking processor.
    In the yml file you may specify the existing processor (amqpEvents) as tracking, but I assume you use that for the processing of messages coming from rabbitMq so in that case add another processor like this:

source: complaintEventsMethod
mode: tracking

  1. you need a @Component Class annotated with


In that class, add this class:

public class ReplayConfiguration {
public void configureProcessors(EventProcessingConfiguration eventProcessingConfiguration) {

And of course, add any Event Handlers you want .

  1. Additional configuration for the Event Store.
    You may missing a few beans in your AmqpConfiguration regarding your event Store. What type of Event Store do you use in your command side?
    You need the exact same configuration for the event Store in the query-side , as you do in the command-side.
    As I have mentioned before, the tracking processor accesses directly the Event Store to get the events from. Not through RabbitMQ but directly. That’s why you have to have configuration for accessing the Event Store, in the service you will place the tracking processor.

I did what you said on itens 1 and 2. No success.

I’m attaching my confi for both (command and query) to see number 3 problems. I’m using in command and query postgres as DB.

If you prefer in order to help me, I can share with you entire project (command and query). (3.03 KB) (4.4 KB)

Yes that maybe helpful. Question: Do you have successfully added events in your event store through the command Side ?


I sent to you in private mode my project.

I’ll post here when I got the solution.