Open oleborne opened 2 months ago
Thanks for reporting this. I would expect the configuration:
@ConditionalOnBean(type = "org.axonframework.springboot.service.connection.AxonServerConnectionDetails")
@Bean
public AxonServerConfiguration axonServerConfigurationWithConnectionDetails(AxonServerConnectionDetails connectionDetails) {
AxonServerConfiguration configuration = new AxonServerConfiguration();
configuration.setComponentName(clientName(applicationContext.getId()));
configuration.setServers(connectionDetails.routingServers());
return configuration;
}
Would make sure the servers from the AxonServerConnectionDetails
is taken before creating the AxonServerConnectionManager
. But apparently that doesn't work all the time.
When debugging, the instance is properly created by this axonServerConfigurationWithConnectionDetails @Bean
but it is then later modified by the ConfigurationPropertiesBindingPostProcessor
.
From the javadoc for ConfigurationPropertiesBindingPostProcessor
:
BeanPostProcessor
to bindPropertySources
to beans annotated withConfigurationProperties
.
So this does not sound like a ordering issue but tied to the fact that this Bean
is annotated with ConfigurationProperties
so will always be bound to properties after being instantiated.
Basic information
Steps to reproduce
@TestContainers
AxonServerContainer
as a field of the test class, annotated with@Container
and@ServiceConnection
axon.axonserver.servers
property in a property file withunknownhost
, which is an unresolvable host.Expected behaviour
The
@ServiceConnection
annotation has precedence over property based configuration and the Axon Server test container can be accessed by the test.Actual behaviour
The property
axon.axonserver.servers
set tounknownhost
overrides the configuration generated thanks to the@ServiceConnection
annotation.By looking at JDBC implementation, this precedence is properly handled by having the connection details object (JdbcConnectionDetails) being an interface distinct from the properties object (DataSourceProperties), allowing for a property based implementation of the connection details and a test container based implementation of the same connection details interface. In Axon Framework, AxonServerConfiguration is both bound to a
ConfigurationProperties
and created by a connection detail factory when using test containers.