Update 32.4. Mixing XA and non-XA JMS connections.md

master
qibaoguang 2015-02-27 21:10:23 +08:00
parent f1e5301a09
commit 5b3186903d
1 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,20 @@
### 32.4. 混合XA和non-XA的JMS连接
当使用JTA时主要的JMS ConnectionFactory bean将是XA aware并参与到分布式事务中。有些情况下你可能需要使用non-XA的ConnectionFactory去处理一些JMS消息。例如你的JMS处理逻辑可能比XA超时时间长。
如果想使用一个non-XA的ConnectionFactory你可以注入nonXaJmsConnectionFactory bean而不是@Primary jmsConnectionFactory bean。为了保持一致jmsConnectionFactory bean将以别名xaJmsConnectionFactor来被使用。
示例如下:
```
// Inject the primary (XA aware) ConnectionFactory
@Autowired
private ConnectionFactory defaultConnectionFactory;
// Inject the XA aware ConnectionFactory (uses the alias and injects the same as above)
@Autowired
@Qualifier("xaJmsConnectionFactory")
private ConnectionFactory xaConnectionFactory;
// Inject the non-XA aware ConnectionFactory
@Autowired
@Qualifier("nonXaJmsConnectionFactory")
private ConnectionFactory nonXaConnectionFactory;
```