[QUESTION]: CorrelationDataProvider Does Not Seem To Be Working

Hi!

We are using JBoss EAP and thus configure Axon via CDI.

Basically, what we want to do is simply forward the entire Axon’s MetaData coming from command handler directly to event handler.

What we are trying is:

DefaultConfigurer.defaultConfiguration()

// some other configuration stuff

.configureCorrelationDataProviders(conf -> Collections.singletonList(Message::getMetaData))

.buildConfiguration();

However, this doesn’t seem working (see the attached CDISetup for more information)

Are we missing something?

Thanks!

CDISetup.java (4.48 KB)

I definitely do not want to distract from the main focus of the question (that I am sure other folks from the team will chime in on). However, I am a little curious - were the existing Axon CDI modules out there ([1], [2]) inadequate? Or was is simply easier/quicker to put together your own producers?

1. https://github.com/kamaladafrica/axon-cdi
2. https://github.com/holisticon/axon-cdi

Hi Reza,

I shall have a look on provided modules, which I was not aware of when started working with Axon.

But still, the question is quite simple - is the provided configuration correct in terms of registering CorrelationDataProvider? If so, what could be the reason of not picking it up?

Thanks!

I definitely agree with you - your original question still stands.

Just to be clear, these two projects are not really officially AxonIQ sanctioned - just community efforts. I am exploring an official Axon CDI module right now, hence my curiosity :-).

That’s great if we have some day official support for CDI and our team will definitely switch to it )

Hi Vladyslav,

the answe to your question really depends on the configuration that’s in the ‘//some other configuration stuff’ part.

If you use default messaging components, the correlation data will automatically be passed on. If you configure your own conmand bus, for example, you’ll also have to pass these explictly to it.

Cheers,

Allard

Hi Allard,

We use SimpleCommandBus (see more verbose configuration in the attached file - my first message):

@Produces
@ApplicationScoped
CommandBus produceCommandBus(CallContextDataMessageDispatchInterceptor interceptor) {
    SimpleCommandBus commandBus = new SimpleCommandBus();
    commandBus.registerDispatchInterceptor(interceptor);
    return commandBus;
}

Should we somehow register CorrelationDataProvider in SimpleCommandBus also in this case?

Answering my own question:

When using custom CommandBus like in my configuration above:

@Produces
@ApplicationScoped
CommandBus produceCommandBus(CallContextDataMessageDispatchInterceptor interceptor) {
    SimpleCommandBus commandBus = new SimpleCommandBus();
    commandBus.registerDispatchInterceptor(interceptor);
    return commandBus;
}

Axon doesn’t register correlation data providers as handler interceptor. So in order to make it work, one should register it manually:

SimpleCommandBus commandBus = new SimpleCommandBus();
commandBus.registerHandlerInterceptor(new CorrelationDataInterceptor<>(configuration.correlationDataProviders()));