> For the complete documentation index, see [llms.txt](https://jack80342.gitbook.io/spring-boot/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jack80342.gitbook.io/spring-boot/ix.-how-to-guides/81.-messaging/81.1-disable-transacted-jms-session.md).

# 81.1 禁用事务JMS会话

如果你的JMS代理不支持事务会话，则必须完全禁用事务支持。如果你创建自己的`JmsListenerContainerFactory`，则不需要做任何事情，因为它在默认情况下不能进行事务处理。如果你想使用`DefaultJmsListenerContainerFactoryConfigurer`来重用Spring Boot的默认值，你可以禁用事务会话。如下所示:

```java
@Bean
public DefaultJmsListenerContainerFactory jmsListenerContainerFactory(
        ConnectionFactory connectionFactory,
        DefaultJmsListenerContainerFactoryConfigurer configurer) {
    DefaultJmsListenerContainerFactory listenerFactory =
            new DefaultJmsListenerContainerFactory();
    configurer.configure(listenerFactory, connectionFactory);
    listenerFactory.setTransactionManager(null);
    listenerFactory.setSessionTransacted(false);
    return listenerFactory;
}
```

前面的示例覆盖了默认工厂，如果应用程序定义了其它工厂，则应该将其应用于其它工厂。
