D. Identifier Generation
The Axon Framework uses an
IdentifierFactoryto generate all identifiers, whether they are for events, commands or queries. The default
IdentifierFactoryuses randomly generated
java.util.UUIDbased identifiers. Although they are very safe to use, the process to generate them does not excel in performance.
IdentifierFactoryis an abstract factory that uses Java's
ServiceLoader(since Java 6) mechanism to find the implementation to use. This means you can create your own implementation of the factory and put the name of the implementation in a file called
ServiceLoadermechanism will detect that file and attempt to create an instance of the class named inside.
There are a few requirements for the
IdentifierFactory. The implementation must:
- 1.Have its fully qualified class name as the contents of the
/META-INF/services/org.axonframework.common.IdentifierFactoryfile on the classpath,
- 2.have an accessible zero-argument constructor,
- 4.be accessible by the context classloader of the application or by the classloader that loaded the
IdentifierFactoryclass, and must
- 5.Be thread-safe.