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

1,002 views
Skip to first unread message

Bharat Srinivasan

unread,
Sep 12, 2017, 5:28:08 AM9/12/17
to Axon Framework Users
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?

Steven van Beelen

unread,
Sep 12, 2017, 5:51:56 AM9/12/17
to Axon Framework Users
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
 

On Tue, Sep 12, 2017 at 11:28 AM Bharat Srinivasan <bharatsr...@gmail.com> wrote:
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?

--
You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bharat Srinivasan

unread,
Sep 12, 2017, 6:17:33 AM9/12/17
to Axon Framework Users
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

Steven van Beelen

unread,
Sep 12, 2017, 7:37:01 AM9/12/17
to Axon Framework Users
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

Bharat Srinivasan

unread,
Sep 13, 2017, 3:17:58 AM9/13/17
to Axon Framework Users
Thank you. I will try that.

Bharat Srinivasan

unread,
Sep 13, 2017, 10:59:21 AM9/13/17
to Axon Framework Users
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.

Allard Buijze

unread,
Sep 13, 2017, 11:30:39 AM9/13/17
to Axon Framework Users
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<Employee> employeeRepository(EntityManagerProvider emp, EventBus eventBus) {
   return new GenericJpaRepository<>(emp, Employee.class, eventBus);
}

Hope this helps.
Allard

Op wo 13 sep. 2017 om 16:59 schreef Bharat Srinivasan <bharatsr...@gmail.com>:
--

Bharat Srinivasan

unread,
Sep 13, 2017, 10:21:08 PM9/13/17
to Axon Framework Users
Hi Allard,

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

Thanks,
Bharat

Bharat Srinivasan

unread,
Sep 13, 2017, 10:53:02 PM9/13/17
to Axon Framework Users
Allard,

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

Thanks,
Bharat

Allard Buijze

unread,
Sep 24, 2017, 12:03:02 AM9/24/17
to Axon Framework Users
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
Reply all
Reply to author
Forward
0 new messages