Skip to content

Conversation

@vpavic
Copy link
Contributor

@vpavic vpavic commented Sep 19, 2023

This commit introduces spring.jms.listener.session-transacted property in order to enable explicit configuration of sessionTransacted on the DefaultMessageListenerContainer.

Prior to this commit, sessionTransacted would be configured implicitly based on presence of JtaTransactionManager.


The background for this change is that some JMS providers (SQS in my case) do not support transactions (see related code). With such a provider, the default behavior of auto-configuration to set sessionTransacted to true when JtaTransactionManager is not present results in a non-working setup that requires something along these lines:

@Bean
DefaultJmsListenerContainerFactory jmsListenerContainerFactory(ConnectionFactory connectionFactory,
        DefaultJmsListenerContainerFactoryConfigurer configurer) {
    DefaultJmsListenerContainerFactory jmsListenerContainerFactory = new DefaultJmsListenerContainerFactory();
    configurer.configure(jmsListenerContainerFactory, connectionFactory);
    jmsListenerContainerFactory.setSessionTransacted(false);
    return jmsListenerContainerFactory;
}

Note that this PR does not change the existing logic - if spring.jms.listener.session-transacted is not set, sessionTransacted will still be set based on presence of JtaTransactionManager.

This commit introduces `spring.jms.listener.session-transacted` property
in order to enable explicit configuration of `sessionTransacted` on the
`DefaultMessageListenerContainer`.

Prior to this commit, `sessionTransacted` would be configured implicitly
based on presence of `JtaTransactionManager`.
@wilkinsona wilkinsona self-assigned this Sep 27, 2023
@wilkinsona wilkinsona changed the title Add support for configuring JMS listener sessionTransacted Add a configuration property for configuring sessionTransacted flag on auto-configured JMS listener container Sep 27, 2023
@wilkinsona wilkinsona added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 27, 2023
@wilkinsona wilkinsona modified the milestones: 3.2.x, 3.2.0-RC1 Sep 27, 2023
wilkinsona pushed a commit that referenced this pull request Sep 27, 2023
This commit introduces `spring.jms.listener.session-transacted` property
in order to enable explicit configuration of `sessionTransacted` on the
`DefaultMessageListenerContainer`.

Prior to this commit, `sessionTransacted` would be configured implicitly
based on presence of `JtaTransactionManager`.

See gh-37473
@vpavic vpavic deleted the gh-37472 branch September 27, 2023 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants