[axonframework] Example Configuration for Axon 3 without spring

Hi William,

With the Configuration API, just start with a:
Configurer configurer = DefaultConfigurer.defaultConfiguration()
Configurer configurer = DefaultConfigurer.jpaConfiguration(…) // this will automatically configure JPA implementations of several components.

From there, check which methods the configurer gives you to get a feel on what you can configure. Once you’re done, just:
Configuration configuration = configurer.buildConfiguration();
// perhaps you want to get some configured elements (such as command bus) before starting. Do that here.

// now you can start sending commands on the command bus.

//when shutting down, you can

Hope this helps.


Thank you very much Allard , this was what i was looking for .

Sorry but , now i have a new problem , I have getting events in my aggregate but, i am not getting any events in my external event handler class .

Here are are the snippets .

AppModule.java has

public class AppModule {
    private Configuration axonConfiguration;
    private ClientStore clientStore;
    public AppModule(){
        clientStore = new ClientMemStore();
        Configurer configurer = DefaultConfigurer.defaultConfiguration();
        EventStore eventStore = new EmbeddedEventStore(new InMemoryEventStorageEngine());
        configurer.configureEventStore(c -> eventStore);
        AggregateConfigurer<ClientAggregate> aggConf = AggregateConfigurer.defaultConfiguration(ClientAggregate.class);
        aggConf.configureRepository(r -> new EventSourcingRepository<>(ClientAggregate.class, eventStore));
        configurer.registerCommandHandler(c -> new ClientCommandHandler(c.repository(ClientAggregate.class)));
        configurer.configureCommandBus(c -> new SimpleCommandBus());
        EventHandlingConfiguration conf = new EventHandlingConfiguration()
                .registerEventHandler(e -> new ClientEventHandler(clientStore));
        axonConfiguration = configurer.buildConfiguration();
        axonConfiguration.onStart(() -> System.out.println("HAS STARTED AXON"));


And the Event handler is what i have below

Am i doing the configuration set up the right way ?

Hi William,

I see you explicitly call start on the EventHandlingConfiguration. That shouldn’t be necessary, and may in fact also prevent it from working correctly.

A few more simplifications:

  • you can use configurer.registerEmbeddedEventStore(new InMemoryStorageEngine()) to create an in-memory event store.
  • no need to configure the EventSourcingRepository. You’ll get one by default
  • no need to configure the CommandBus. You’ll get the SimpleCommandBus by default.

Let me know if that worked for you.



Thanks this got everything working .