package es.wealth.backoffice.config
import com.mongodb.MongoClient
import com.mongodb.MongoCredential
import com.mongodb.ServerAddress
import es.wealth.backoffice.domain.model.familygroup.FamilyGroup
import es.wealth.backoffice.domain.model.familygroup.FamilyGroupRepository
import es.wealth.backoffice.domain.model.familygroup.event.FamiliyGroupEventHandler
import es.wealth.backoffice.domain.service.FamilyGroupDomainService
import org.axonframework.config.Configurer
import org.axonframework.config.EventHandlingConfiguration
import org.axonframework.eventsourcing.AggregateFactory
import org.axonframework.eventsourcing.EventCountSnapshotTriggerDefinition
import org.axonframework.eventsourcing.EventSourcingRepository
import org.axonframework.eventsourcing.eventstore.EmbeddedEventStore
import org.axonframework.eventsourcing.eventstore.EventStore
import org.axonframework.mongo.eventsourcing.eventstore.DefaultMongoTemplate
import org.axonframework.mongo.eventsourcing.eventstore.MongoEventStorageEngine
import org.axonframework.mongo.eventsourcing.eventstore.MongoTemplate
import org.axonframework.mongo.eventsourcing.eventstore.documentperevent.DocumentPerEventStorageStrategy
import org.axonframework.serialization.json.JacksonSerializer
import org.axonframework.spring.eventsourcing.SpringAggregateSnapshotter
import org.axonframework.spring.eventsourcing.SpringAggregateSnapshotterFactoryBean
import org.axonframework.spring.eventsourcing.SpringPrototypeAggregateFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.ApplicationContext
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Scope
@Configuration
class AxonConfiguration {
@Autowired
FamilyGroupRepository familyGroupRepository
@Autowired
FamilyGroupDomainService familyGroupDomainService
@Bean(name = "axonMongoTemplate")
MongoTemplate axonMongoTemplate() {
// TODO config
MongoClient mongoClient = new MongoClient(new ServerAddress("mongodb", 27017), [MongoCredential.createCredential("wealth-eventstore", "wealth-eventstore", "wealth-eventstore".getChars())])
MongoTemplate template = new DefaultMongoTemplate(mongoClient,
"wealth-eventstore", "familyGroup", "familyGroup-snapshot");
template
}
@Bean
JacksonSerializer jacksonSerializer() {
new JacksonSerializer()
}
@Bean
EventStore embeddedEventStore() {
MongoEventStorageEngine storageEngine = new MongoEventStorageEngine(jacksonSerializer(), null, axonMongoTemplate(), new DocumentPerEventStorageStrategy())
EventStore eventStore = new EmbeddedEventStore(storageEngine)
eventStore
}
@Bean
SpringAggregateSnapshotterFactoryBean springAggregateSnapshotterFactoryBean() {
new SpringAggregateSnapshotterFactoryBean()
}
@Bean
@Scope("prototype")
AggregateFactory<FamilyGroup> transactionAggregateFactory() {
// TODO generic?
AggregateFactory<FamilyGroup> aggregateFactory = new SpringPrototypeAggregateFactory<FamilyGroup>()
aggregateFactory.setPrototypeBeanName("familyGroup")
aggregateFactory;
}
@Bean
@Scope("prototype")
FamilyGroup familyGroup() {
// TODO generic?
new FamilyGroup(familyGroupRepository, familyGroupDomainService)
}
@Bean
EventSourcingRepository<FamilyGroup> axonFamilyGroupRepository(EventStore eventStore, SpringAggregateSnapshotterFactoryBean springAggregateSnapshotterFactoryBean, ApplicationContext applicationContext) {
SpringAggregateSnapshotter snapshotter = springAggregateSnapshotterFactoryBean.getObject()
snapshotter.setApplicationContext(applicationContext)
EventCountSnapshotTriggerDefinition snapshotTriggerDefinition = new EventCountSnapshotTriggerDefinition(
snapshotter,
2);
new EventSourcingRepository(FamilyGroup, eventStore, snapshotTriggerDefinition)
}
@Autowired configure(Configurer configurer,EventHandlingConfiguration ehConfiguration){
// define an EventHandlingConfiguration
ehConfiguration.registerEventHandler({conf -> new FamiliyGroupEventHandler()});
// the module needs to be registered with the Axon Configuration
configurer.registerModule(ehConfiguration);
}
/*
@Bean
AggregateAnnotationCommandHandler<FamilyGroup> commandHandler(EventSourcingRepository eventSourcingRepository) {
new AggregateAnnotationCommandHandler<FamilyGroup>(FamilyGroup, eventSourcingRepository)
}
*/
}
package es.wealth.backoffice.domain.model.familygroup.event
import groovy.util.logging.Slf4j
import org.axonframework.eventhandling.EventHandler
@Slf4j
class FamiliyGroupEventHandler {
@EventHandler
void handle(FamilyGroupCreatedEvent familyGroupCreatedEvent) {
log.info "onCreate: ${familyGroupCreatedEvent}"
//familyGroupRepository.create(this)
}
}
--
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 axonframewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
package es.wealth.backoffice.config
import com.mongodb.MongoClient
import com.mongodb.MongoCredential
import com.mongodb.ServerAddress
import es.wealth.backoffice.domain.model.familygroup.FamilyGroup
import org.axonframework.eventsourcing.EventCountSnapshotTriggerDefinition
import org.axonframework.eventsourcing.EventSourcingRepository
import org.axonframework.eventsourcing.eventstore.EmbeddedEventStore
import org.axonframework.eventsourcing.eventstore.EventStorageEngine
import org.axonframework.eventsourcing.eventstore.EventStore
import org.axonframework.mongo.eventsourcing.eventstore.DefaultMongoTemplate
import org.axonframework.mongo.eventsourcing.eventstore.MongoEventStorageEngine
import org.axonframework.mongo.eventsourcing.eventstore.MongoTemplate
import org.axonframework.mongo.eventsourcing.eventstore.documentperevent.DocumentPerEventStorageStrategy
import org.axonframework.serialization.json.JacksonSerializer
import org.axonframework.spring.eventsourcing.SpringAggregateSnapshotter
import org.axonframework.spring.eventsourcing.SpringAggregateSnapshotterFactoryBean
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.ApplicationContext
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
@Configuration
class AxonConfiguration {
@Bean(name = "axonMongoTemplate")
MongoTemplate axonMongoTemplate() {
// TODO config
MongoClient mongoClient = new MongoClient(new ServerAddress("mongodb", 27017), [MongoCredential.createCredential("wealth-eventstore", "wealth-eventstore", "wealth-eventstore".getChars())])
MongoTemplate template = new DefaultMongoTemplate(mongoClient,
"wealth-eventstore", "familyGroup", "familyGroup-snapshot");
template
}
@Bean
JacksonSerializer jacksonSerializer() {
new JacksonSerializer()
}
@Bean
EventStorageEngine embeddedEventStore() {
MongoEventStorageEngine storageEngine = new MongoEventStorageEngine(jacksonSerializer(), null, axonMongoTemplate(), new DocumentPerEventStorageStrategy())
//EventStore eventStore = new EmbeddedEventStore(storageEngine)
storageEngine
}
/*@Bean
EventSourcingRepository<FamilyGroup> axonFamilyGroupRepository(EventStore eventStore, SpringAggregateSnapshotterFactoryBean springAggregateSnapshotterFactoryBean, ApplicationContext applicationContext) {
SpringAggregateSnapshotter snapshotter = springAggregateSnapshotterFactoryBean.getObject()
snapshotter.setApplicationContext(applicationContext)
EventCountSnapshotTriggerDefinition snapshotTriggerDefinition = new EventCountSnapshotTriggerDefinition(
snapshotter,
2)
new EventSourcingRepository(FamilyGroup, eventStore, snapshotTriggerDefinition)
}*/
/*
@Bean
AggregateAnnotationCommandHandler<FamilyGroup> commandHandler(EventSourcingRepository eventSourcingRepository) {
new AggregateAnnotationCommandHandler<FamilyGroup>(FamilyGroup, eventSourcingRepository)
}
*/
}
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.
--
You received this message because you are subscribed to a topic in the Google Groups "Axon Framework Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/axonframework/03pKZLhYIp0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to axonframework+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "Axon Framework Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/axonframework/03pKZLhYIp0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to axonframewor...@googlegroups.com.
--
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 axonframewor...@googlegroups.com.
package es.wealth.backoffice.config
import com.mongodb.MongoClient
import com.mongodb.MongoCredential
import com.mongodb.ServerAddress
import es.wealth.backoffice.domain.model.client.event.ClientEventHandler
import es.wealth.backoffice.domain.model.contract.Contract
import es.wealth.backoffice.domain.model.familygroup.FamilyGroup
import es.wealth.backoffice.domain.model.kyc.Kyc
import es.wealth.backoffice.domain.model.person.NaturalPerson
import org.axonframework.config.EventHandlingConfiguration
import org.axonframework.eventhandling.EventBus
import org.axonframework.eventhandling.EventHandler
import org.axonframework.eventhandling.SimpleEventHandlerInvoker
import org.axonframework.eventsourcing.EventCountSnapshotTriggerDefinition
import org.axonframework.eventsourcing.EventSourcingRepository
import org.axonframework.eventsourcing.eventstore.EmbeddedEventStore
import org.axonframework.eventsourcing.eventstore.EventStore
import org.axonframework.mongo.eventsourcing.eventstore.DefaultMongoTemplate
import org.axonframework.mongo.eventsourcing.eventstore.MongoEventStorageEngine
import org.axonframework.mongo.eventsourcing.eventstore.MongoTemplate
import org.axonframework.mongo.eventsourcing.eventstore.documentperevent.DocumentPerEventStorageStrategy
import org.axonframework.serialization.json.JacksonSerializer
import org.axonframework.spring.eventsourcing.SpringAggregateSnapshotter
import org.axonframework.spring.eventsourcing.SpringAggregateSnapshotterFactoryBean
import org.axonframework.spring.stereotype.Aggregate
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.ApplicationContext
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Primary
@Configuration
class AxonConfiguration {
@Bean(name = "axonMongoTemplate")
MongoTemplate axonMongoTemplate() {
// TODO config
MongoClient mongoClient = new MongoClient(new ServerAddress("mongodb", 27017), [MongoCredential.createCredential("wealth-eventstore", "wealth-eventstore", "wealth-eventstore".getChars())])
MongoTemplate template = new DefaultMongoTemplate(mongoClient,
"wealth-eventstore", "events", "events-snapshot");
template
}
@Bean
JacksonSerializer jacksonSerializer() {
new JacksonSerializer()
}
@Primary
@Bean(name = "eventBusser")
EventStore embeddedEventStore() {
MongoEventStorageEngine storageEngine = new MongoEventStorageEngine(jacksonSerializer(), null, axonMongoTemplate(), new DocumentPerEventStorageStrategy())
EventStore eventStore = new EmbeddedEventStore(storageEngine)
eventStore
}
/*@Bean
SpringAggregateSnapshotterFactoryBean springAggregateSnapshotterFactoryBean() {
new SpringAggregateSnapshotterFactoryBean()
}
@Bean
EventSourcingRepository<FamilyGroup> axonFamilyGroupRepository(EventStore eventStore, SpringAggregateSnapshotterFactoryBean springAggregateSnapshotterFactoryBean, ApplicationContext applicationContext) {
SpringAggregateSnapshotter snapshotter = springAggregateSnapshotterFactoryBean.getObject()
snapshotter.setApplicationContext(applicationContext)
EventCountSnapshotTriggerDefinition snapshotTriggerDefinition = new EventCountSnapshotTriggerDefinition(
snapshotter,
2)
new EventSourcingRepository(FamilyGroup, eventStore, snapshotTriggerDefinition)
}
@Bean
EventSourcingRepository<NaturalPerson> axonNaturalPersonRepository(EventStore eventStore, SpringAggregateSnapshotterFactoryBean springAggregateSnapshotterFactoryBean, ApplicationContext applicationContext) {
SpringAggregateSnapshotter snapshotter = springAggregateSnapshotterFactoryBean.getObject()
snapshotter.setApplicationContext(applicationContext)
EventCountSnapshotTriggerDefinition snapshotTriggerDefinition = new EventCountSnapshotTriggerDefinition(
snapshotter,
2)
new EventSourcingRepository(NaturalPerson, eventStore, snapshotTriggerDefinition)
}
@Bean
EventSourcingRepository<Contract> axonContractRepository(EventStore eventStore, SpringAggregateSnapshotterFactoryBean springAggregateSnapshotterFactoryBean, ApplicationContext applicationContext) {
SpringAggregateSnapshotter snapshotter = springAggregateSnapshotterFactoryBean.getObject()
snapshotter.setApplicationContext(applicationContext)
EventCountSnapshotTriggerDefinition snapshotTriggerDefinition = new EventCountSnapshotTriggerDefinition(
snapshotter,
2)
new EventSourcingRepository(Contract, eventStore, snapshotTriggerDefinition)
}
@Bean
EventSourcingRepository<Kyc> axonKycRepository(EventStore eventStore, SpringAggregateSnapshotterFactoryBean springAggregateSnapshotterFactoryBean, ApplicationContext applicationContext) {
SpringAggregateSnapshotter snapshotter = springAggregateSnapshotterFactoryBean.getObject()
snapshotter.setApplicationContext(applicationContext)
EventCountSnapshotTriggerDefinition snapshotTriggerDefinition = new EventCountSnapshotTriggerDefinition(
snapshotter,
2)
new EventSourcingRepository(Kyc, eventStore, snapshotTriggerDefinition)
}*/
/*
@Bean
AggregateAnnotationCommandHandler<FamilyGroup> commandHandler(EventSourcingRepository eventSourcingRepository) {
new AggregateAnnotationCommandHandler<FamilyGroup>(FamilyGroup, eventSourcingRepository)
}
*/
}
package es.wealth.backoffice.domain.model.client.event
import groovy.util.logging.Slf4j
import org.axonframework.eventhandling.EventHandler
import org.springframework.stereotype.Component
@Component
@Slf4j
class ClientEventHandler {
@EventHandler
void onEvent(ClientCreatedEvent clientCreatedEvent){
log.info("IT WORKSS!!!!!!YEAHH")
}
}
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.
--
You received this message because you are subscribed to a topic in the Google Groups "Axon Framework Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/axonframework/03pKZLhYIp0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to axonframework+unsubscribe@googlegroups.com.
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.
--
You received this message because you are subscribed to a topic in the Google Groups "Axon Framework Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/axonframework/03pKZLhYIp0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to axonframework+unsubscribe@googlegroups.com.
--
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.
--
You received this message because you are subscribed to a topic in the Google Groups "Axon Framework Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/axonframework/03pKZLhYIp0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to axonframework+unsubscribe@googlegroups.com.
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.
--
You received this message because you are subscribed to a topic in the Google Groups "Axon Framework Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/axonframework/03pKZLhYIp0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to axonframework+unsubscribe@googlegroups.com.
--
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.
--
You received this message because you are subscribed to a topic in the Google Groups "Axon Framework Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/axonframework/03pKZLhYIp0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to axonframework+unsubscribe@googlegroups.com.
--
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.
--
You received this message because you are subscribed to a topic in the Google Groups "Axon Framework Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/axonframework/03pKZLhYIp0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to axonframework+unsubscribe@googlegroups.com.
private SubscribingEventProcessor subscribingEventProcessor(Configuration conf, String name, List<?> eh,
Function<Configuration, SubscribableMessageSource<? extends EventMessage<?>>> messageSource) {
return new SubscribingEventProcessor(name,
new SimpleEventHandlerInvoker(eh,
conf.parameterResolverFactory(),
conf.getComponent(
ListenerInvocationErrorHandler.class,
LoggingErrorHandler::new)),
messageSource.apply(conf),
DirectEventProcessingStrategy.INSTANCE,
PropagatingErrorHandler.INSTANCE,
conf.messageMonitor(SubscribingEventProcessor.class,
name));
}
private static class BeanMethodInterceptor implements MethodInterceptor, ConditionalCallback {
/**
* Enhance a {@link Bean @Bean} method to check the supplied BeanFactory for the
* existence of this bean object.
* @throws Throwable as a catch-all for any exception that may be thrown when invoking the
* super implementation of the proxied method i.e., the actual {@code @Bean} method
*/
@Override
public Object intercept(Object enhancedConfigInstance, Method beanMethod, Object[] beanMethodArgs,
MethodProxy cglibMethodProxy) throws Throwable {
ConfigurableBeanFactory beanFactory = getBeanFactory(enhancedConfigInstance);
String beanName = BeanAnnotationHelper.determineBeanNameFor(beanMethod);
// Determine whether this bean is a scoped-proxy
Scope scope = AnnotatedElementUtils.findMergedAnnotation(beanMethod, Scope.class);
if (scope != null && scope.proxyMode() != ScopedProxyMode.NO) {
String scopedBeanName = ScopedProxyCreator.getTargetBeanName(beanName);
if (beanFactory.isCurrentlyInCreation(scopedBeanName)) {
beanName = scopedBeanName;
}
}
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.
--
You received this message because you are subscribed to a topic in the Google Groups "Axon Framework Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/axonframework/03pKZLhYIp0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to axonframework+unsubscribe@googlegroups.com.
--
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.
--
You received this message because you are subscribed to a topic in the Google Groups "Axon Framework Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/axonframework/03pKZLhYIp0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to axonframework+unsubscribe@googlegroups.com.
--
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.
--
You received this message because you are subscribed to a topic in the Google Groups "Axon Framework Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/axonframework/03pKZLhYIp0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to axonframework+unsubscribe@googlegroups.com.
--
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.
--
You received this message because you are subscribed to a topic in the Google Groups "Axon Framework Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/axonframework/03pKZLhYIp0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to axonframework+unsubscribe@googlegroups.com.
@Bean
EventStore embeddedEventStore() {
MongoEventStorageEngine storageEngine = new MongoEventStorageEngine(jacksonSerializer(), null, axonMongoTemplate(), new
DocumentPerEventStorageStrategy())
EventStore eventStore = new EmbeddedEventStore(storageEngine)
eventStore
}
@Bean(name = 'eventBas')
@Primary
EventBus eventBas(EventStore eventStore) {
eventStore
}
@Bean
SpringAggregateSnapshotterFactoryBean springAggregateSnapshotterFactoryBean() {
new SpringAggregateSnapshotterFactoryBean()
}
@Bean
EventSourcingRepository<FamilyGroup> axonFamilyGroupRepository(EventStore eventStore, SpringAggregateSnapshotterFactoryBean
springAggregateSnapshotterFactoryBean, ApplicationContext applicationContext) {
SpringAggregateSnapshotter snapshotter = springAggregateSnapshotterFactoryBean.object
snapshotter.setApplicationContext(applicationContext)
EventCountSnapshotTriggerDefinition snapshotTriggerDefinition = new EventCountSnapshotTriggerDefinition(
snapshotter,
SNAPSHOT_TRESHOLD)
new EventSourcingRepository(FamilyGroup, eventStore, snapshotTriggerDefinition)
}
@Bean
EventSourcingRepository<NaturalPerson> axonNaturalPersonRepository(EventStore eventStore, SpringAggregateSnapshotterFactoryBean
springAggregateSnapshotterFactoryBean, ApplicationContext applicationContext) {
SpringAggregateSnapshotter snapshotter = springAggregateSnapshotterFactoryBean.object
snapshotter.setApplicationContext(applicationContext)
EventCountSnapshotTriggerDefinition snapshotTriggerDefinition = new EventCountSnapshotTriggerDefinition(
snapshotter,
SNAPSHOT_TRESHOLD)
new EventSourcingRepository(NaturalPerson, eventStore, snapshotTriggerDefinition)
}
@Bean
EventSourcingRepository<Contract> axonContractRepository(EventStore eventStore, SpringAggregateSnapshotterFactoryBean
springAggregateSnapshotterFactoryBean, ApplicationContext applicationContext) {
SpringAggregateSnapshotter snapshotter = springAggregateSnapshotterFactoryBean.object
snapshotter.setApplicationContext(applicationContext)
EventCountSnapshotTriggerDefinition snapshotTriggerDefinition = new EventCountSnapshotTriggerDefinition(
snapshotter,
SNAPSHOT_TRESHOLD)
new EventSourcingRepository(Contract, eventStore, snapshotTriggerDefinition)
}
@Bean
EventSourcingRepository<Kyc> axonKycRepository(EventStore eventStore, SpringAggregateSnapshotterFactoryBean
springAggregateSnapshotterFactoryBean, ApplicationContext applicationContext) {
SpringAggregateSnapshotter snapshotter = springAggregateSnapshotterFactoryBean.object
snapshotter.setApplicationContext(applicationContext)
EventCountSnapshotTriggerDefinition snapshotTriggerDefinition = new EventCountSnapshotTriggerDefinition(
snapshotter,
SNAPSHOT_TRESHOLD)
new EventSourcingRepository(Kyc, eventStore, snapshotTriggerDefinition)
}
@Autowired
void configure(EventBus eventBus, EventHandlingConfiguration ehConfig) {
ehConfig.registerSubscribingEventProcessor(PROCESSOR_CLASSPATH) { c -> eventBus }
//ehConfig.registerEventHandler({c -> new ClientEventHandler()})
ehConfig.byDefaultAssignTo(PROCESSOR_CLASSPATH)
}
...