all events contains different correlationId and traceId. I can see that correlationId is unique for each message. How to achieve that all metadata will contain the same traceId? Where do I need to register MessageOriginProvider for saga?
On each EventProcessor you (manually) create, you should register a CorrelationDataInterceptor. On that interceptor, you can register all CorrelationDataProviders (of which OriginProvider is one). If you use the configuration API to define processors, these interceptors are registered automatically.
If you register this interceptor on all components that handle messages (CommandBus, Event Processor and perhaps some custom components that handle messages directly from the Event Bus/Store), then the traceId will be copied between all messages in the cause-effect chain.
I still don’t understand that. In this case, when I create only CommandBus by myself where do I need to register CorrelationDataInterceptor to have same traceId in all events ? I’ve updated the sample.
I found some time to dive into this. It seems like the AuditDataProviders aren’t properly picked up for Sagas. They are for “regular” event handlers, just not for Saga instances.
As a workaround, temporarily, you will probably need to define your own processor (e.g. SubscribingProcessor) and SagaManager. On the processor, you can register the CorrelationDataInterceptor (which you also registered on the Command Bus).