How to disable event store and just use event bus for event propagation and handling?

I am building a spring boot application, where I want to use Axon 3 just for issuing commands and handling the corresponding events. I do not want any storage of events. How can I achieve it?

Hi Bharat,

Taking that you’re using the axon-spring-boot-starter dependency to wire the Axon beans, specifying your own EventBus bean should suffice in this scenario.
The EventBus to use would probably be the SimpleEventBus.

Hope this helps!

Cheers,

Steven

I created a bean that instantiates SimpleEventBus, but I encounter the error below

`
Caused by: java.lang.IllegalStateException: Default configuration requires the use of event sourcing. Either configure an Event Store to use, or configure a specific repository implementation for class com.sample.Employee

`

Hi Bharat,

So that exception already gives you a pointer what has to be done right: you need to specify a repository for you Employee aggregate.
Assuming you’ve put the @Aggregate annotation on your Employee class, the default aggregate repository created by the axon spring boot setup would be the EmployeeRepository.
That said I’m guessing however that you’re already creating your own EmployeeRepository for a different purpose than your aggregate, so the aggregate repo bean is probably overridden by your own EmployeeRepository.

That leaves you with two options I can currently think off:

  1. Adjust the name of your own EmployeeRepository to not clash with the Employee aggregate repo
  2. Add your own aggregate repository for Employee (check Axon’s repository implementations for which to use in your situation) and specify the name you give that repository in the @Aggregate(repository = {insert-name-here} on your aggregate.

Hope this helps!

Cheers,

Steven

Thank you. I will try that.

Sorry, but I couldn’t get it running. I have my code here https://github.com/bharat-srinivasan/my-axonbank. It would be great if you can point out to the mistake I am doing.
I created this project following one of the tutorials on Axon 3 from Youtube.

Hi Bharat,

I can’t find any configuration (other than defaults) in the project. Could you point me to the location where it should be?

Note that the bean name of your repository should be “employeeRepository”, if it’s for the aggregate called Employee. So in Spring, you’d have a method Repository employeeRepository(EntityManagerProvider emp, EventBus eventBus) {
return new GenericJpaRepository<>(emp, Employee.class, eventBus);
}

Hope this helps.
Allard

Hi Allard,

Do I need to have a repository when I just want to use Event Bus and not event store?

Thanks,
Bharat

Allard,

I was able to get it running by creating a bean for InMemoryStorageEngine.

Thanks,
Bharat

Hi Bharat,

it may work, but probably won’t last long in production with these settings. The in-memory storage engine stores all published events in memory. Configuring it will still cause an Event Store to be used.

If you just want an Event Bus, configure a SimpleEventBus instead. That way, events aren’t stored at all.

Cheers,

Allard