You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am wondering if it would be appropriate to add @ConditionalOnSingleCandidate to jmsListenerContainerFactory? I have an application that sends messages to multiple brokers and as such i create multiple ConnectionFactory and JMSTemplate beans. My application does not need to listen to any JMS destinations. my application fails to start because it is finding multiple ConnectionFactory beans and as such unable to create the default jmsListenerContainerFactory bean. For clarity, my application does not need a listener.
if i understand this correctly we are getting into this position because due to the MATCHED conditions listed below.
@ConditionalOnClass({ Message.class, JmsTemplate.class })MATCHES those ARE on the classpath @ConditionalOnBean(ConnectionFactory.class)MATCHES i have multiple CopnnectionFactories @Import(JmsAnnotationDrivenConfiguration.class)
@ConditionalOnMissingBean(name = "jmsListenerContainerFactory")MATCHES i did not define my own
and then that method is requiring just one ConnectionFactory parameter but I have made multiple.
would adding @ConditionalOnSingleCandidate be a quality of life improvement here? Would it make it so that a listenerContainerFactory is not created and my application can start without error? or am i misunderstanding the use/purpose of that annotation?
workarounds i played with trying to get my application to start
i set spring.jms.listener.auto-startup=false however the problem persisted
i can make a ConnectionFactory Bean @Primary but.... i dont want or need a listener so it feels like that is making the error go away by conforming to its current design. its allowing its current design to dictate how my application is configured which is incorrect and misleading to other developers. none of my connections are necessarily Primary
currently i have created my own jmsListenerContainerFactory bean so that spring-boot does not try to autoconfigure its own. this is messier than the @Primary work around from a code quality point of view but at least i know i am killing the creation of a listenerContainerFactory as early as i can see to kill it.
or have I missed something and I am way off base? is there some other property to communicate to spring "please do not register any listeners"?
Thanks
The text was updated successfully, but these errors were encountered:
@danlangford you're right and the auto-configuration was not designed to account for the multi-datasource scenario. One solution that you didn't mention is to exclude JmsAutoConfiguration for the time being.
We've done that work in 2.0 for JPA and DataSource but I am afraid we should have revisited this part as well. Let's try to tackle that for the next feature release.
wilkinsona
changed the title
appropriate to add @ConditionalOnSingleCandidate to jmsListenerContainerFactory?
Make jmsListenerContainerFactory @ConditionalOnSingleCandidate
Jun 1, 2018
I am wondering if it would be appropriate to add
@ConditionalOnSingleCandidate
tojmsListenerContainerFactory
? I have an application that sends messages to multiple brokers and as such i create multipleConnectionFactory
andJMSTemplate
beans. My application does not need to listen to any JMS destinations. my application fails to start because it is finding multipleConnectionFactory
beans and as such unable to create the defaultjmsListenerContainerFactory
bean. For clarity, my application does not need a listener.if i understand this correctly we are getting into this position because due to the MATCHED conditions listed below.
AutoConfigure on class
JmsAutoConfiguration
:spring-boot/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JmsAutoConfiguration.java
Lines 48 to 53 in 97a71be
@ConditionalOnClass({ Message.class, JmsTemplate.class })
MATCHES those ARE on the classpath@ConditionalOnBean(ConnectionFactory.class)
MATCHES i have multiple CopnnectionFactories@Import(JmsAnnotationDrivenConfiguration.class)
Configure
JmsAnnotationDrivenConfiguration
:spring-boot/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JmsAnnotationDrivenConfiguration.java
Lines 42 to 44 in 97a71be
@ConditionalOnClass(EnableJms.class)
MATCHES that class is on the classpathspring-boot/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JmsAnnotationDrivenConfiguration.java
Lines 75 to 79 in 97a71be
@ConditionalOnMissingBean(name = "jmsListenerContainerFactory")
MATCHES i did not define my ownand then that method is requiring just one ConnectionFactory parameter but I have made multiple.
would adding
@ConditionalOnSingleCandidate
be a quality of life improvement here? Would it make it so that a listenerContainerFactory is not created and my application can start without error? or am i misunderstanding the use/purpose of that annotation?workarounds i played with trying to get my application to start
spring.jms.listener.auto-startup=false
however the problem persistedConnectionFactory
Bean@Primary
but.... i dont want or need a listener so it feels like that is making the error go away by conforming to its current design. its allowing its current design to dictate how my application is configured which is incorrect and misleading to other developers. none of my connections are necessarily PrimaryjmsListenerContainerFactory
bean so that spring-boot does not try to autoconfigure its own. this is messier than the@Primary
work around from a code quality point of view but at least i know i am killing the creation of a listenerContainerFactory as early as i can see to kill it.or have I missed something and I am way off base? is there some other property to communicate to spring "please do not register any listeners"?
Thanks
The text was updated successfully, but these errors were encountered: