Spring: Upcaster order

That’s the approach/workaorund I chose.

Configurer#registerEventUpcaster(Function<Configuration, EventUpcaster>) is invoked by org.axonframework.spring.config.SpringAxonAutoConfigurer which collects all beans of type EventUpcaster. Unfortunately SpringAxonAutoConfigurer is not optimized for customization with its single registerBeanDefinitions method and a couple of private methods. Therefore for the time being I decided to copy the whole class and customized de.bmiag.mars.axon.client.MarsSpringAxonAutoConfigurer.registerEventUpcasters(Configurer):

private void registerEventUpcasters( final Configurer configurer ) {
	Arrays.stream( beanFactory.getBeanNamesForType( EventUpcasterChain.class ) )
			.forEach( name -> configurer.registerEventUpcaster( c -> getBean( name, c ) ) );
}

The EventUpcasterChain is registered in the Spring context and it expects a List of EventUpcasters. This list is provided (and ordered) by Spring, respecting the @Order annotation.

Copying the whole class is a dirty hack for sure, but it works for the moment until you can provide a better solution.

Oliver