Author |
Message
|
yalmasri |
Posted: Mon Jul 30, 2012 3:55 am Post subject: Backout is Not Working in 2PC |
|
|
Centurion
Joined: 18 Jun 2008 Posts: 110
|
I'm trying to use WMQ as a TM to coordinate units of work between queue and Oracle DB. On machine A, I have WMQ server 7.0.1.5, Oracle client, and a standalone java application trying to put a message to a local queue and update the database in one global txn. Oracle database 10.2.0.4.0 is installed on machine B, and both machines are running SunOS 5.10.
Steps followed for setup on machine A:
1. export ORACLE_HOME=/oracle/product/10.2.0/db_1
2. export ORACLE_SID=testsid
3. cd /opt/mqm/samp/xatm --> make -f xaswit.mak oraswitd
4. cd /var/mqm/exits & /var/mqm/exits64 --> verified that both contain oraswitd
5. cd /var/mqm/qmgrs/MYQM --> edit qm.ini adding:
XAResourceManager:
Name=OracleRM
SwitchFile=oraswitd
XAOpenString=Oracle_XA+Acc=P/foo/bar+SesTm=30+SqlNet=TEST+threads=true
ThreadOfControl=THREAD
6. Verified that qm.ini has:
ExitsDefaultPath=/var/mqm/exits/
ExitsDefaultPath64=/var/mqm/exits64/
7. cd /oracle/product/10.2.0/db_1/network/admin/ --> verified that tnsnames.ora has the following:
TEST =
(DESCRIPTION =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = 111.222.333.444)
(PORT = 1234)
)
(CONNECT_DATA =
(SERVER = dedicated)
(SID = testsid)
)
)
8. Restarted QM
Now to machine B:
1. cd /oracle/product/10.2.0/db_1/javavm/install --> picked up initjvm.sql & initxa.sql and executed them on database --> success
2. executed: grant select on DBA_PENDING_TRANSACTIONS to foo;
The test code is simple:
Code: |
Hashtable<String, Comparable<?>> properties = new Hashtable<String, Comparable<?>>();
properties.put(MQC.THREAD_AFFINITY_PROPERTY, new Boolean(true));
properties.put(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_BINDINGS);
MQQueueManager qmgr = new MQQueueManager("MYQM", properties);
OracleXADataSource ds = new OracleXADataSource();
ds.setTNSEntryName("TEST");
ds.setUser("foo");
ds.setPassword("bar");
java.sql.Connection con = qmgr.getJDBCConnection(ds);
qmgr.begin();
MQQueue queue = qmgr.accessQueue("TEST", MQC.MQOO_OUTPUT);
MQMessage outMessage = new MQMessage();
outMessage.format = MQC.MQFMT_STRING;
outMessage.writeString("backout is working");
MQPutMessageOptions pmo = new MQPutMessageOptions();
pmo.options = MQC.MQPMO_SYNCPOINT;
queue.put(outMessage, pmo);
con.setAutoCommit(false);
Statement stmt = con.createStatement();
stmt.executeQuery("UPDATE test SET desc = 'backout is NOT working' WHERE id = 1");
stmt.close();
qmgr.backout();
con.close();
queue.close();
qmgr.disconnect(); |
Now to the problem, when I say
it's working fine, but when I say
as in the code above, no message is sent to queue as expected, but the database record is unexpectedly getting updated with the value "backout is NOT working"!
Am I missing something obvious?
Last edited by yalmasri on Tue Jul 31, 2012 2:53 am; edited 2 times in total |
|
Back to top |
|
 |
bruce2359 |
Posted: Mon Jul 30, 2012 5:17 am Post subject: |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9469 Location: US: west coast, almost. Otherwise, enroute.
|
Which WMQ Client? Is the WMQ Extended Transactional Client installed? _________________ I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live. |
|
Back to top |
|
 |
yalmasri |
Posted: Mon Jul 30, 2012 6:01 am Post subject: |
|
|
Centurion
Joined: 18 Jun 2008 Posts: 110
|
My standalone application is on the same machine where the WMQ server is (I'm connecting using bindings mode as it's clear from the code), so not sure what to answer you here.
For ETC, I guess yea:
Code: |
-bash-3.00$ pkgparam mqm CLASSES
none base java jre keyman man runtime samples server sol_client txclient |
But, do I really need ETC here? From what I know, distributed transactions are supported by default in bindings mode, and ETC is required only for client mode connections.
Anyway, I placed com.ibm.mqetclient.jar in my classpath and I got the same result. |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Jul 30, 2012 7:01 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
the MQ 7.0 infocenter, which has just started throwing a bad proxy gateway error, indicates that you have to use a specific MQ provided switch file to do JTA/JDBC coordination with base java.
You're using the Oracle switch file, not the JTA switch file that comes with MQ.
EDIT: Scratch that, I see you've just renamed the switch file in your make.
But you're still in the wrong directory.
http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.csqzaw.doc/ja11290_.htm
You need to be in /opt/mqm/java/lib/jdbc or /opt/mqm/java/lib64/jdbc rather than /opt/mqm/samp/xatm |
|
Back to top |
|
 |
yalmasri |
Posted: Tue Jul 31, 2012 1:13 am Post subject: |
|
|
Centurion
Joined: 18 Jun 2008 Posts: 110
|
|
Back to top |
|
 |
yalmasri |
Posted: Tue Jul 31, 2012 2:51 am Post subject: |
|
|
Centurion
Joined: 18 Jun 2008 Posts: 110
|
Unlike what that document said:
A 32-bit switch library is stored in the /java/lib/jdbc directory, and a 64-bit switch library is stored in the /java/lib64/jdbc directory
the switch files went to the exits path like before... so far so good.
Now I tried to run the sample but it threw an exception on qmgr.begin() saying:
Code: |
com.ibm.mq.MQException: MQJE001: Completion Code '2', Reason '2195'. |
What could that possibly be? |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Jul 31, 2012 4:33 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Look for the corresponding FDC... Then look the probeid up on the IBM site  _________________ MQ & Broker admin |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Jul 31, 2012 4:52 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
That's for creating the Oracle Switch File for use from C/C++ applications.
Not from Java. Which you're using.
yalmasri wrote: |
One question though, when switch file was in /var/mqm/exits or /var/mqm/exits64 I pointed it to QM using ExitPath stanza in qm.ini, how do I point to it the new path (/opt/mqm/java/lib/jdbc or /opt/mqm/java/lib64/jdbc)? You know it's not easy to start a QM even in a development environment. |
As you saw, the make file fixed that for you. Also, the doc say "is stored", this likely means "there's a precompiled version there". There are certainly jdbcora.dll files in my local windows install.
So I'd see if you have local files as well, and try those in place of your compiled versions.
And, yes, you do always need to restart the queue manager whenever you make any changes to the XA configuration. Sorry!
You also likely need to make sure that the queue manager is starting up in a shell that has knowledge of ORA_HOME.... |
|
Back to top |
|
 |
yalmasri |
Posted: Tue Jul 31, 2012 5:27 am Post subject: |
|
|
Centurion
Joined: 18 Jun 2008 Posts: 110
|
fjb_saper wrote: |
Look for the corresponding FDC... Then look the probeid up on the IBM site  |
I looked into /var/mqm/errors but couldn't find any file with the process number for the application, as a matter of fact I couldn't find any file with today's date. Does that make sense?
On another try, I was reading another file under /var/mqm/qmgrs/MYQM/errors (AMQERR02.LOG), and it says:
AMQ7604: The XA resource manager 'OracleRM' was not available when called
for xa_open. The queue manager is continuing without this resource manager.
EXPLANATION:
The XA resource manager 'OracleRM' has indicated that it is not available,
by returning XAER_RMERR on an xa_open request or XAER_RMFAIL when called for
something else. Normally this indicates that the resource manager has been shut
down. In this case the resource manager cannot participate in any new
transactions. Any in-flight transactions in which it was involved will be
backed out, and any transactions in which it is in-doubt will only be resolved
when contact with the resource manager is re-established. A further message
will be issued when the queue manager has been able to do this. If the problem
occurred on an xa_open request, and the resource manager should be available,
then there may be a configuration problem.
ACTION:
Try to establish the reason why the resource manager is unavailable. It may be
that an invalid XAOpenString has been defined for the resource manager in the
'qm.ini' configuration file. If this is the case, stop and then restart the
queue manager so that any change will be picked up. Alternatively, the queue
manager may be reaching a resource constraint with this resource manager. For
example, the resource manager may not be able to accommodate all of the queue
manager processes being connected at one time, you may need to alter one of its
tuning parameters.
This is pointing to one of two issues, either the RM is not available, or an error in xa_open string. I dismissed the first because I know for sure it's available, and I tried again and again with the same error. Now left the second. Can you see any issue with the string for XAOpenString?
Last edited by yalmasri on Sat Aug 04, 2012 12:38 am; edited 1 time in total |
|
Back to top |
|
 |
yalmasri |
Posted: Tue Jul 31, 2012 5:34 am Post subject: |
|
|
Centurion
Joined: 18 Jun 2008 Posts: 110
|
mqjeff wrote: |
That's for creating the Oracle Switch File for use from C/C++ applications.
Not from Java. Which you're using. |
The application was working all the way except for the backout on the database. Is it well expected that a switch file for C/C++ was going to help you out that much? In fact the other switch library is not working with me at all so far.
mqjeff wrote: |
You also likely need to make sure that the queue manager is starting up in a shell that has knowledge of ORA_HOME.... |
Did you mean ORACLE_HOME?
Last edited by yalmasri on Tue Jul 31, 2012 5:45 am; edited 1 time in total |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Jul 31, 2012 5:44 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
yalmasri wrote: |
mqjeff wrote: |
That's for creating the Oracle Switch File for use from C/C++ applications.
Not from Java. Which you're using. |
The application was working all the way except for the backout on the database. Is it well expected that a switch file for C/C++ was going to help you out that much? |
I'm not suggesting it would help you. I'm explaining that the instructions you were following are valid for a programming environment that you are not using.
yalmasri wrote: |
In fact the other switch library is not working with me at all so far. |
Well, in theory it's actually working better. The other one didn't inform your application that XA was not enabled or working....
yalmasri wrote: |
mqjeff wrote: |
You also likely need to make sure that the queue manager is starting up in a shell that has knowledge of ORA_HOME.... |
That's satisfied already |
Okay. It's still worth double-checking, since you are having errors that could potentially indicate a failure to connect to the database. And all I'm saying here is that *I* would double-check it, if it were me. Probably four or five times. I'm not saying that you *haven't* or that you've done anything wrong.
Otherwise, yes, I agree that your XAOpen string is also worth examining based on what you've said.
Particularly since, having double-checked it, http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.csqzaw.doc/ja11290_.htm says that ThreadOfControl must be Process and not Thread. |
|
Back to top |
|
 |
yalmasri |
Posted: Wed Aug 01, 2012 1:07 am Post subject: |
|
|
Centurion
Joined: 18 Jun 2008 Posts: 110
|
Let's reformulate our thoughts:
- I built my switch libraries using make -f xaswit.mak oraswitd on /opt/mqm/samp/xatm and every thing looks perfect except for backout(), which was not working for the database only.
- Jeff suggested that I'm using the wrong procedure to build the switch library and that I should use make oracle on /opt/mqm/java/lib/jdbc instead.
- When I rebuilt and restarted my QM, I got an error suggesting that I might be using a wrong xa_open() string, even though the same exact string worked absolutely well with the other switch library
If someone who practically experienced this could just tell me that despite what looks a step backwards we're on the right track, then let's focus on our xa_open() string and see what's wrong with it. I in fact have some personal doubts about it. |
|
Back to top |
|
 |
yalmasri |
Posted: Wed Aug 01, 2012 3:29 am Post subject: |
|
|
Centurion
Joined: 18 Jun 2008 Posts: 110
|
BTW, the trace file has this entry FWIW,
Code: |
xaolgn_help: XAER_RMERR; OCIServerAttach failed. ORA-0. |
|
|
Back to top |
|
 |
yalmasri |
Posted: Wed Aug 01, 2012 4:06 am Post subject: |
|
|
Centurion
Joined: 18 Jun 2008 Posts: 110
|
Looking for any clue that may help, I edited jdbcora (I know it's binary), and I've seen this clear text:
Quote: |
MQStart (MQ_64) called
Process id: %d
Database switch flags : %d
Database name: %s
%s %p %s No JVM Specified
XA_Open called
Process id: %d
Open string: %s
RMId: %d
flags: %08x
XA_Open returned %d
Issuing call via Java ERROR - There was no JVM pointer
Thread attach failed
com/ibm/mq/XAtoJTA Can't find XAtoJTA class
Can't get XAtoJTA Class Monitor
Locked XAtoJTA class
Failed to unlock XAtoJTA class
Can't find XAtoJTA class (via NewGlobalRef)
Failed to unlock XAtoJTA class
XAOpen (Ljava/lang/String;III)I Can't find XAOpen
Invalid XAOpen string
Unexpected exception
Java XAOpen returned %d
XA_Close called
Process id: %d
RMId: %d
XA_Close returned %d
Issuing call via Java Thread attach failed
com/ibm/mq/XAtoJTA Can't find XAtoJTA class
XAClose (Ljava/lang/String;II)I Can't find XAClose
Invalid XAClose string
Unexpected exception
Java XAClose returned %d
|
Should that mean anything? Can anybody open your jdbcora and see if you have this text as well? |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Aug 01, 2012 4:43 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Okay.
So the docs that you pointed at in the first place are for building a switch file that only applies to C/C++ applications, despite the fact that it says it's a switch file for Oracle.
Java does not use C/C++. So you *cannot* use a switch file built from that source for your Java code.
IT WAS NOT working fine previously. IT WAS NOT providing XA. It merely Failed to Tell You that it was *not* working, and instead SILENTLY FAILED to perform the backout.
The correct Java switch file that you have built ALSO requires that you CHANGE the ThreadOfControl parameter to "PROCESS". You apparently still have it set to "Thread".
My belief is that if you change that to Process instead of Thread, then it will start working and not throw errors.
I may not have actually done this in recent years, but that does not mean I am off base here. If you wish to get a more reliable source of information, you should be simultaneously working a PMR. |
|
Back to top |
|
 |
|