35.5 Mixing XA and non-XA JMS connections

When using JTA, the primary JMS ConnectionFactory bean will be XA aware and participate in distributed transactions. In some situations you might want to process certain JMS messages using a non-XA ConnectionFactory. For example, your JMS processing logic might take longer than the XA timeout.

If you want to use a non-XA ConnectionFactory you can inject the nonXaJmsConnectionFactory bean rather than the @Primary jmsConnectionFactory bean. For consistency the jmsConnectionFactory bean is also provided using the bean alias xaJmsConnectionFactory.

For example:

// 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;

results matching ""

    No results matching ""