spring-boot icon indicating copy to clipboard operation
spring-boot copied to clipboard

Add non-transactable configure method to DefaultJmsListenerContainerFactoryConfigurer

Open philwebb opened this issue 3 years ago • 4 comments

See https://github.com/spring-projects/spring-framework/issues/28009#issuecomment-1031857962

Rather than recommending that developers call configurer.configure(listenerFactory, connectionFactory) then undo the transaction manager with setTransactionManager(null) we should offer a version that doesn't set it in the first place.

philwebb avatar Feb 07 '22 19:02 philwebb

The org.springframework.boot.docs.howto.messaging.disabletransactedjmssession.MyJmsConfiguration Kotlin and Java samples will need to be updated after the fix. The @Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") annotation should also be removed from the Kotlin sample.

philwebb avatar Feb 07 '22 19:02 philwebb

It would work without any new public API if we set the transaction manager on the configure to null before calling configure. That feels more flexible to me than a new configure variant, however, the configurer's a bean so we shouldn't really mutate it. Perhaps it should be in prototype scope like RestTemplateBuilder?

wilkinsona avatar Apr 11 '22 13:04 wilkinsona

I am not sure we should do anything. DefaultJmsListenerContainerFactoryConfigurer takes a JtaTransactionManager on purpose as a strong signal you need to use distributed transactions. If you don't use JTA, then these are usually the regular sessionTransacted thing, which is the recommended setup.

If you have configured JTA in your app, I think that disabling it for JMS access is actually quite unusual.

snicoll avatar Apr 12 '22 06:04 snicoll

If we take that route, should we re-evaluate #7394 and #7463?

wilkinsona avatar Apr 12 '22 07:04 wilkinsona