# 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;
}
```

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jack80342.gitbook.io/spring-boot/ix.-how-to-guides/81.-messaging/81.1-disable-transacted-jms-session.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
