MessageConsumer/MessageProducer vs QueueSender/QueueReceiver

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.

Answer

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.

Leave a Reply

Your email address will not be published. Required fields are marked *