Author |
Message
|
kevinb11 |
Posted: Tue Feb 22, 2011 12:54 pm Post subject: Weblogic 11g WebSphere 6.0 JMS XA Transaction Question |
|
|
Newbie
Joined: 22 Feb 2011 Posts: 6
|
Hi All-
I am doing a POC and I'm kinda stuck on a XA problem. I am working from a common IBM example that worked fine but now I'm trying to get it to work with XA code. The error message I get is:
Exception:
Code: |
MQJMS2007: failed to send message to MQ
MQJE001: Completion Code 2, Reason 2072
|
My code is as follows:
Code: |
public void testSend() {
XAQueueConnectionFactory queueConnectionFactory = null;
XAQueueConnection queueConnection = null;
XAQueueSession xaqueueSession = null;
Context jndiContext = null;
Queue queue = null;
QueueSender queueSender = null;
QueueSession queueSession = null;
String queueName = "jms/WLMyReplyQueue";
try {
jndiContext = new InitialContext();
queueConnectionFactory = (XAQueueConnectionFactory) jndiContext.lookup("jms/WLSenderQCF");
System.out.println("looked up QueueConnectionFactory: " + queueConnectionFactory);
queue = (Queue)jndiContext.lookup(queueName);
System.out.println("looked up Queue: " + queue);
} catch (NamingException e) {
System.out.println("JNDI Problem: ");
e.printStackTrace();
}
try {
queueConnection = queueConnectionFactory.createXAQueueConnection();
xaqueueSession = queueConnection.createXAQueueSession();
Message msg = xaqueueSession.createTextMessage("Hello From Test");
queueSession = xaqueueSession.getQueueSession();
queueSender = queueSession.createSender(queue);
queueSender.send(msg);
System.out.println("Message send");
} catch (Exception e) {
System.out.println("Exception: ");
e.printStackTrace();
if (e instanceof JMSException) {
((JMSException) e).getLinkedException().printStackTrace();
}
} finally {
try {
System.out.println("Closing Connection");
queueSession.close();
queueConnection.close();
} catch (Exception e) {
System.out.println("Exception: ");
e.printStackTrace();
if (e instanceof JMSException) {
((JMSException) e).getLinkedException().printStackTrace();
}
}
}
}
|
Any thoughts?
Thanks!
Kevin |
|
Back to top |
|
 |
Vitor |
Posted: Tue Feb 22, 2011 12:57 pm Post subject: Re: Weblogic 11g WebSphere 6.0 JMS XA Transaction Question |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
kevinb11 wrote: |
Any thoughts? |
From the documentation:
Quote: |
This reason code can also occur on the MQGET, MQPUT, and MQPUT1 calls when an external unit-of-work coordinator is being used. If that coordinator requires an explicit call to start the unit of work, but the application has not issued that call prior to the MQGET, MQPUT, or MQPUT1 call, reason code MQRC_SYNCPOINT_NOT_AVAILABLE is returned. |
I don't know Weblogic from a hole in the ground - does it require such a call? Is the queue manager properly configured to participate in an XA transaction? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
kevinb11 |
Posted: Tue Feb 22, 2011 1:07 pm Post subject: |
|
|
Newbie
Joined: 22 Feb 2011 Posts: 6
|
Thanks for the reply. Where would I find in WebSphere explorer if Queue is set up to do XA transactions? I've been looking.... |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Feb 22, 2011 2:29 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
kevinb11 wrote: |
Thanks for the reply. Where would I find in WebSphere explorer if Queue is set up to do XA transactions? I've been looking.... |
Nowhere.
A queue is never set up for XA transactions.
A QCF/TCF/CF needs to be setup for XA transactions.
In your case you did not specify whether the qmgr was on the same box as your Weblogic server, nor did you specify whether you are using a client connection (channel). Now if you are using a client connection, did you make certain that you have
- a properly licensed ETC (Extended Transactional Client).
- the corresponding jar file for the etc on the classpath
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
kevinb11 |
Posted: Tue Feb 22, 2011 3:02 pm Post subject: |
|
|
Newbie
Joined: 22 Feb 2011 Posts: 6
|
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Feb 22, 2011 9:03 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
After having defined everything as per the second link, did you review your configuration as per the first link?
You are trying to do a multiphase commit, can you show us the code where you create the relevant javax.jms.Session ?
I gather this is it:
Code: |
queueConnection = queueConnectionFactory.createXAQueueConnection();
xaqueueSession = queueConnection.createXAQueueSession();
Message msg = xaqueueSession.createTextMessage("Hello From Test");
queueSession = xaqueueSession.getQueueSession();
queueSender = queueSession.createSender(queue);
queueSender.send(msg); |
I would suggest that you use following:
Code: |
queueSession = queueConnection.createSession(true, Session.AUTO_ACKNOWLEDGE); |
and let us know how it went.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
kevinb11 |
Posted: Tue Feb 22, 2011 9:21 pm Post subject: |
|
|
Newbie
Joined: 22 Feb 2011 Posts: 6
|
This code compiles, but it bombs on queueSender.send(msg);
Code: |
public void testSend() {
XAQueueConnectionFactory queueConnectionFactory = null;
XAQueueConnection queueConnection = null;
XAQueueSession xaqueueSession = null;
Context jndiContext = null;
Queue queue = null;
QueueSender queueSender = null;
QueueSession queueSession = null;
String queueName = "jms/WLMyReplyQueue";
try {
jndiContext = new InitialContext();
queueConnectionFactory = (XAQueueConnectionFactory) jndiContext.lookup("jms/WLSenderQCF");
System.out.println("looked up QueueConnectionFactory: " + queueConnectionFactory);
queue = (Queue)jndiContext.lookup(queueName);
System.out.println("looked up Queue: " + queue);
} catch (NamingException e) {
System.out.println("JNDI Problem: ");
e.printStackTrace();
}
try {
queueConnection = queueConnectionFactory.createXAQueueConnection();
xaqueueSession = queueConnection.createXAQueueSession();
Message msg = xaqueueSession.createTextMessage("Hello From Test");
queueSession = xaqueueSession.getQueueSession();
queueSender = queueSession.createSender(queue);
queueSender.send(msg);
System.out.println("Message send");
} catch (Exception e) {
System.out.println("Exception: ");
e.printStackTrace();
if (e instanceof JMSException) {
((JMSException) e).getLinkedException().printStackTrace();
}
} finally {
try {
System.out.println("Closing Connection");
queueSession.close();
queueConnection.close();
} catch (Exception e) {
System.out.println("Exception: ");
e.printStackTrace();
if (e instanceof JMSException) {
((JMSException) e).getLinkedException().printStackTrace();
}
}
}
}
|
|
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Feb 22, 2011 9:26 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
fjb_saper wrote: |
I would suggest that you use following:
Code: |
queueSession = queueConnection.createSession(true, Session.AUTO_ACKNOWLEDGE); |
and let us know how it went.
Have fun  |
Have you tried it?
You might also want to take this warning into consideration:
Quote: |
The XAQueueConnection interface is optional. JMS providers are not required to support this interface. This interface is for use by JMS providers to support transactional environments. Client programs are strongly encouraged to use the transactional support available in their environment, rather than use these XA interfaces directly. |
_________________ MQ & Broker admin |
|
Back to top |
|
 |
kevinb11 |
Posted: Tue Feb 22, 2011 9:55 pm Post subject: |
|
|
Newbie
Joined: 22 Feb 2011 Posts: 6
|
I read that also today and was unsure. That code does run though. Will test more tomorrow along with a XA database update wrapped in one transaction. Will post back results. Thank you very much for your input. |
|
Back to top |
|
 |
|