Multiple EventStore

578 views
Skip to first unread message

jorge.oliv...@santander.co.uk

unread,
Jul 4, 2018, 2:31:11 PM7/4/18
to Axon Framework Users
Hi all,

It is possible to use axon framework with more than one EvenStore?? Let me explain, in DDD one of the basic things is split the business in subdomains/bounded context etc... if we have a very big application and lot of events is better to have different event stores for the different parts in the application but is this posible with Axon?? for example in the same app have two TrackingProcessors/EventListeners that each one listen to a different EventStore? 

Best Regards

Frans van Buul

unread,
Jul 4, 2018, 2:41:13 PM7/4/18
to axonfr...@googlegroups.com
Hi Jorge,

Yes, that's absolutely possible and also reasonable in the situation you sketch.

Axon, especially in combination with Spring Boot autoconfiguration, gives a lot of sensible defaults. If you have JPA on the classpath, it will configure a single JpaEventStorageEngine, use that to construct a single EmbeddedEventStore, and if you're using tracking event processors, those will be using this single event store as their messageSource. But you can configure all of this in a different way if you like, using multiple event stores and choose which tracking event processors go to which event store.

In the enterprise version of our AxonDB event store offering, we support the notion of having multiple contexts, which are logically separated event stores, for exactly the reason you mention.

Kind regards,

Frans van Buul
AxonIQ
+31 6 5068 2984

 

--
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 axonframework+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jorge.oliv...@santander.co.uk

unread,
Jul 15, 2018, 1:47:20 PM7/15/18
to Axon Framework Users
Hi Frans,

Thanks for your reply :-)

Putting a concrete example for use MongoDB as Event Store I understand how to setup different "MongoEventStorageEngine", basically i can create different "MongoTemplates" using different "MongoClient" that point to different MongoDB servers or different data bases, and here is where i start to have doubt:
1. I suppose that i should create a "EmbeddedEventStore" for each "MongoEventStorageEngine" right? i have seen the AxonAutoConfiguration class and iñm not sure what is a "MessageMonitor"?
2. Reading the documentation seems like  "Tracking Processors" are created automatically using the package names (https://docs.axonframework.org/part-iii-infrastructure-components/event-processing#assigning-handlers-to-processors), so how can we organize/setup the different Tracking Proccessor to get events from different event stores/EmbeddedEventStore? is using the "source" property? how can we choose this "source" for each EmbeddedEventStore?
3. Talking about a Saga, how are the event processor assigned to a Saga? can a Saga listen for event from multiple EventStores??

Best Regards
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.

Steven van Beelen

unread,
Jul 18, 2018, 5:53:58 AM7/18/18
to axonfr...@googlegroups.com
Hi Jorge,

Let me go through your questions one by one.


1. I suppose that i should create a "EmbeddedEventStore" for each "MongoEventStorageEngine" right? i have seen the AxonAutoConfiguration class and iñm not sure what is a "MessageMonitor"?
Your assumption is correct. The easiest thing to have multiple 'streamable event sources' is to introduce several `EmbeddedEventStores`, all with their own `EventStorageEninge`. The `MessageMonitor` can be wired into your `EventBus`, as well as your `CommandBus` and `EventProcessors` to get message ingestion metrics based on Dropwizard/Metrics.
2. Reading the documentation seems like  "Tracking Processors" are created automatically using the package names (https://docs.axonframework.org/part-iii-infrastructure-components/event-processing#assigning-handlers-to-processors), so how can we organize/setup the different Tracking Proccessor to get events from different event stores/EmbeddedEventStore? is using the "source" property? how can we choose this "source" for each EmbeddedEventStore?
Yes, Axon will automatically wire everything for you in a Spring environment, but you can very easily override that. In Axon 3.3 you can use the `EventProcessingConfiguration` (versions below 3.3 have the `EventHandlingConfiguration`) to instantiate your TrackingEventProcessors. You do this by using the `registerTrackingEventProcessor()` function. The `name` parameter is the name of the processing group you've given to your Tracking Event Processor. The important part in configuring your Tracking Event Processor this way, is by providing the right `StreamableMessageSource` (which I referred to in answer 1). The `StreamableMessageSource` is an interface which the `EmbeddedEventStore` implements. As you've specified several `EmbeddedEventStores`, you can select the rigth one to be used by the right `TrackingEventProcessor`.
3. Talking about a Saga, how are the event processor assigned to a Saga?
Saga's receive their events by means of Event Processors as well, which is configurable by using the `SagaConfiguration`. This class allows you to configure your saga to use either a Subscribing or a Tracking Event Processor (so, identical to regular event handling components). 
can a Saga listen for event from multiple EventStores??
No, this currently is not an option, although we do see this as a reoccurring question. Hence we do have it on the roadmap to be introduced in our products (Framework, AxonHub and AxonDB), eventually. As such I cannot give you a time frame when this will be introduced.

Hope this helps you out for now Jorge.

Cheers,
Steven

Laura Winnen

unread,
May 20, 2020, 5:00:19 AM5/20/20
to Axon Framework Users
Hi Steven

Is there any update already for a saga listening to multiple event stores?

Thanks!

Laura Winnen

Op woensdag 18 juli 2018 11:53:58 UTC+2 schreef Steven van Beelen:
To unsubscribe from this group and stop receiving emails from it, send an email to axonfr...@googlegroups.com.

Steven van Beelen

unread,
Sep 15, 2020, 7:53:56 AM9/15/20
to Axon Framework Users
Hi Laura,

Yes, I can actually give you a hand on the matter.
As of Axon Framework 4.2, there is the option to specify a MultiStreamableMessageSource as the StreamableMessageSource for a TrackingEventProcessor.
It thus does mean your Saga is required to be backed by a TrackingEventProcessor.

The MultiStreamableMessageSource provides a builder, allowing you to provide several StreamableMessageSource instances to it.
Axon's EmbeddedEventStore is one such StreamableMessageSource you can use here for example.

If you are using Axon Server on the other hand, leverage the MultiStreamableMessageSource to connect several contexts together.
The way to achieve this is by using the AxonServerEventStore#createStreamableMessageSourceForContext(String) method, which will return you just such a StreamableMessageSource to give to a MultiStreamableMessageSource.

Trusting this helps you out further Laura!

Cheers,
Steven

Reply all
Reply to author
Forward
0 new messages