Hi @Sneha_Bagri and welcome to the forum!
First and foremost, if you’re going to run your Axon Framework application with multiple instances, I would strongly recommend to look into distributed version of Axon’s Message Buses.
The easiest step to take here, is to start playing around with Axon Server actually.
It will give you a distributed command, event, and query bus, with all the required characteristics you would expect.
So, apart from that, we can move to the PSEP.
Firstly, I think it’s beneficial you’re selecting the PSEP for your environment as the Event Processor, as it provides more flexibility for scaling your instances.
However, if you set the
maxClaimedSegments to one, you lose the flexibility.
Although by setting it to 1 you enforce each instance of your application receives a segment, you would increase your eventual consistency massively.
To achieve the flexibility you are looking into, it’s best to leave
maxClaimedSegments to its default (
Short.MAX_VALUE) and move to a setup where you consciously tell instances to scale those segments between one another. This is something you can, for example, set through Axon Server, by adjusting the load balancing strategy to a “per thread” setting.
In doing so, Axon Server will take up the role of “telling” different Axon Framework instances to release and claim. segments, until an equal distribution is achieved.
Besides Axon Server, AxonIQ’s working on a dashboard you can connect your application to, which will provide similar functionality (and more).
And if that also doesn’t work out…well then I recommend you checking the operations on the
StreamingEventProcessor. It provides an API to split, merge, release, and claim segments, which are the exact operations Axon Server and the aforementioned dashboard uses.
Concluding, I hope this helps you further, @Sneha_Bagri!