Reputation: 159
Can someone explain me should i use MQXAQueueConnectionFactory if i want just read messages by @JmsListener in Spring Boot?
I read messages with MQXAQueueConnectionFactory and with MQQueueConnectionFactory and i don't see the difference. If i make exception in listener method i see that message delivered again and again.
In this time setSessionTransacted setting is true and setTransactionManager setting is null for DefaultJmsListenerContainerFactory:
public void configure(DefaultJmsListenerContainerFactory factory,
ConnectionFactory connectionFactory) {
Assert.notNull(factory, "Factory must not be null");
Assert.notNull(connectionFactory, "ConnectionFactory must not be null");
factory.setConnectionFactory(connectionFactory);
factory.setPubSubDomain(this.jmsProperties.isPubSubDomain());
if (this.transactionManager != null) {
factory.setTransactionManager(this.transactionManager); // null
}
else {
factory.setSessionTransacted(true);
}
...
Upvotes: 1
Views: 1756
Reputation: 35008
As the name suggests, MQXAQueueConnectionFactory
is used when working with XA transactions. Technically speaking MQXAQueueConnectionFactory
implements javax.jms.XAConnectionFactory
which ultimately provides access to the other XA-related connection, context, session, and resource interfaces. Typically these would be used by the underlying framework (e.g. Java EE or Spring) along with the transaction manager to coordinate your XA transaction between multiple resource managers (e.g. a JMS provider and a JDBC database).
Since you're not working with XA transactions then you should just use MQQueueConnectionFactory
.
To be clear, an XA transaction is different from a transacted JMS session (which is what you've configured).
Upvotes: 3