Created
August 30, 2017 19:59
-
-
Save mrook/701ba6d5499f1cd8727599ae7e9f2532 to your computer and use it in GitHub Desktop.
Axon TrackingEventProcessor example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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