there is a CorrelationDataInterceptor that allows you to register meta data with the Unit of Work (using registerCorrelationDataProvider(…) ). That MetaData is automatically attached to all messages created in the scope of that Unit of Work.
If you use Spring Autoconfiguration or the Axon Configuration API to define your components, you will get an interceptor that automatically adds a correlationId and traceId to all the messages (see MessageOriginProvider).
while checking the code for how these things are wired, it seems like there is currently no Spring-friendly way of wiring them. They are provided by the AxonConfiguration, but it there is no way to get them in there using Spring (at least not without doing something ‘dirty’).
It’s a simple change to get them ‘autowired’ based on their availability in the application context.
I have submitted issue #240.