Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MessageConsumer/MessageProducer vs QueueSender/QueueReceiver

Tags:

java

jms

xa

Is the MessageConsumer/MessageProducer the XA equivalent of QueueSender/QueueReceiver?

As far as I can understand the MessageConsumer/MessageProducer are better used in a XA context.

In my app I want to switch from QueueConnectionFactory, QueueConnection, QueueSession to their XA equivalent and for that I would need to use MessageConsumers/Receivers instead of QueueSenders and QueueReceivers.

like image 236
Sergiu Avatar asked Jul 11 '11 11:07

Sergiu


1 Answers

Is the MessageConsumer/MessageProducer the XA equivalent of QueueSender/QueueReceiver?

No. QueueSender extends MessageProducer, and provides some additional queue-specific methods. It has nothing to do with XA. The same relationship exists between QueueReceiver and MessageConsumer.

As far as I can understand the MessageConsumer/MessageProducer are better used in a XA context.

Again, this has nothing to do with XA. It's generally better to write to the MessageConsumer/MessageProducer interfaces in any JMS code, unless you specifically need the extra methods provided by QueueSender/QueueReceiver.

In my app I want to switch from QueueConnectionFactory, QueueConnection, QueueSession to their XA equivalent and for that I would need to use MessageConsumers/Receivers instead of QueueSenders and QueueReceivers.

No. Whether you use XA or not has nothing to do with your choice of API interface. The XA behaviour is determined by which QueueConnectionFactory you obtain from the application server. Most will provide you with either an XA or a non-XA QueueConnectionFactory, generally on a different JNDI path, and it is up to you to obtain the appropriate one.

Once you have the correct QueueConnectionFactory, your application should not care whether XA is used or not.

like image 166
skaffman Avatar answered Sep 21 '22 15:09

skaffman