Skip to content

Instantly share code, notes, and snippets.

@mablae
Forked from mrook/trackedproj.java
Created August 30, 2017 20:03
Show Gist options
  • Save mablae/17581bd4252c28868fc7e4eefa5dfc66 to your computer and use it in GitHub Desktop.
Save mablae/17581bd4252c28868fc7e4eefa5dfc66 to your computer and use it in GitHub Desktop.
Axon TrackingEventProcessor example
@Configuration
public class ProjectionsConfiguration {
@Autowired
private EventHandlingConfiguration eventHandlingConfiguration;
@Autowired
private EventStorageEngine eventStorageEngine;
@PostConstruct
public void startTrackingProjections() throws ClassNotFoundException {
ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false);
scanner.addIncludeFilter(new AnnotationTypeFilter(TrackedProjection.class));
for (BeanDefinition bd : scanner.findCandidateComponents("org.demo")) {
Class<?> aClass = Class.forName(bd.getBeanClassName());
ProcessingGroup processingGroup = aClass.getAnnotation(ProcessingGroup.class);
String name = Optional.ofNullable(processingGroup).map(ProcessingGroup::value).orElse(aClass.getPackage().getName());
registerTrackingProcessor(name);
}
}
private void registerTrackingProcessor(String name) {
eventHandlingConfiguration.registerTrackingProcessor(name);
}
}
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface TrackedProjection {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment