Turn off event sourcing

Hi there

I’m about switching from event sourcing to JPA based state storage of the aggregates. As everything is now stored in the jpa tables I wanted to turn off event sourcing.
Unfortunately the JpaAutoConfiguration tiggers the creation of an EventStorageEngine. Later on this leads to an issue when the event bus supplies the event to the created event storage engine which tries to store the event in the database.

So my question how can I turn off the creation of the event storage subsystem.

Cheers
Marco

P.S: I’m using axon-spring-boot-starter 3.3.3

In the meanwhile I found a possibility to turn it off.

`

@EnableAutoConfiguration(exclude = {JpaAutoConfiguration.class})
public class InitialConfiguration {

@Bean
public EntityManagerProvider entityManagerProvider() {
return new ContainerManagedEntityManagerProvider();
}

`

As I still need the EntityManagerProvider I copied this part from the JpaAutoConfiguration.

Is this the way to achieve this?

Hi Marco,

if you annotate your aggregates with Jpa’s @Entity, Axon will automatically configure state-stored aggregates for you. No additional configuration is necessary. Alternatively, you can configure a specific Repository implementation for your Aggregate. Axon will use that repository instead of configuring (probably event sourcing) one for you.

Cheers,

Hi Allard

When I understand the JpaAutoConfiguration correctly an EventStorageEngine is created in any case. Even though I don’t need one anymore.

`

@Configuration
public class JpaAutoConfiguration {

@ConditionalOnMissingBean({EventStorageEngine.class, EventStore.class})
@Bean
public EventStorageEngine eventStorageEngine(Serializer serializer,
PersistenceExceptionResolver persistenceExceptionResolver,
@Qualifier(“eventSerializer”) Serializer eventSerializer,
AxonConfiguration configuration,
EntityManagerProvider entityManagerProvider,
TransactionManager transactionManager) {
return new JpaEventStorageEngine(serializer, configuration.upcasterChain(),
persistenceExceptionResolver, eventSerializer, null, entityManagerProvider,
transactionManager, null, null, true);
}

`

Cheers
Marco

Hi Marco,

seems you are right. The @ConditionalOnMissingBean should also include an EventBus, which would allow you to skip the configuration of a StorageEngine when there is an EventBus configured already.

Cheers,