Load the aggregate from the repository without the locking aggregate

Hello,

I am getting org.axonframework.common.lock.LockAcquisitionFailedException error when trying to load the aggregate state using the EventSourcingrepository. I need to load the aggregate to read data from the aggregate state.

Does Axon 4.2 provide a repository which does not lock the aggregate when loading the aggregate? Do I need to write my own custom repository?

Thanks

Hi,

big questions that this raises is: why? Apparently, you’re trying to load and aggregate that is already being used. Loading one without a lock could be dangerous, as you will have two instances (or possibly the same instance) where concurrent modifications may occur. If you’re trying to load an aggregate to query its state, then consider using query models for that.

You can actually configure the LockFactory on the repository. By default, it uses a PessimisticLockFactory, but you can use the NullLockFactory. Beware that you don’t use this repository instance for commands, though, as it may cause them to be concurrently executed, resulting in downstream exceptions.

Kind regards,