I’m experimenting with a PoC to set up an environment that works with hibernate multitenancy support end-to-end. It’s a spring-boot app with the latest axon-framework version without axon-server.
It was pretty straightforward to set it up with the Subscribing event processor because everything is handled in one thread so both the EventStore and readModel in event handlers have access to tenant identifiers and its also easy to keep a separate EventStore per tenant.
Now I’m trying to replace subscribing event processor with a tracking one. I found out that MultiStreamableMessageSource was designed to support multiple event sources and combine them into one.
Based on that I was able more or less to implement something like shown in the picture A bellow.
However, I see two disadvantages:
- I need to keep the token in a shared “public” schema/DB. I would like to keep the token in a tenant-specific dataSource so it won’t grow too much and to have an easy way to remove it with all tenant-related stuff.
- Too much workload generated by one tenant for a shared tracking processor could influence other tenants
Instead of MultiStreamableMessageSource i would prefer to have a dedicated TrackingProcessor per tenant with dedicated TokenStore that operates only on one tenant EventStore.
The concept is shown in picture B bellow.
I’m not sure if it’s possible and how to configure multiple TrackingProcessors to work with the same Class that implements @EventHandlers.
I can find a lot of information on how to connect multiple EventHandlers to one Tracking processor but not how to do it vice versa.
I see that there is a builder to create a TrackingEventProcessor that could potentially allow to set up handlers manually
but config only allows to register a name, eventStore and config class:
config.registerTrackingEventProcessor(processorName, c -> EmbeddedEventStore.builder()
Any help would be appreciated.