I'm trying to create a fallback ConnectionFactory in case the JndiConnectionFactoryAutoConfiguration did not create one for me.
Here's what the class looks like
@Configuration
@AutoConfigureAfter(JndiConnectionFactoryAutoConfiguration.class)
@ConditionalOnMissingBean(ConnectionFactory.class)
@ConditionalOnClass(ConnectionFactory.class)
public class JmsFallbackAutoConfiguration {
@Bean
@ConditionalOnMissingBean
ConnectionFactory fallbackConfiguration() {
ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
System.out.println("Created: " + activeMQConnectionFactory);
return activeMQConnectionFactory;
}
}
What I'm expecting is spring boot starts, some auto configuration is going on, we get to JndiConnectionFactoryAutoConfiguration which notices that I have spring.jms.jndi-name set and creates the ConnectionFactory bean.
Then, at some point, I'm expecting it to get to JmsFallbackAutoConfiguration when it should notice that we already have a ConnectionFactory (which was configured by JndiConnectionFactoryAutoConfiguration) and move on.
But that's not what happens, JmsFallbackAutoConfiguration always executes and I don't know what I'm missing.
Sample project here https://github.com/apixandru/case-study/tree/master/spring-boot-weblogic-jms/spring-boot-weblogic-jms-war