| home / infca / mq / mqxa (navigation links) | Dame fuerzas para no ser arrogante |
| MQXA on MQ | Dubtes | Links | End |
|
The XA specification defines how applications use a transaction manager to coordinate a distributed transaction across multiple resource managers. The XA interface defines the contract between a resource manager and a transaction manager in a distributed transaction processing (DTP) environment. Distributed transactions enable independent resources - such as MQ and DB2 - to participate in a single unit of work that assures data integrity, even if one resource cannot commit or crashes while the transaction is in progress. A transaction will commit only if all resources can commit successfully - otherwise it is rolled back. WebSphere MQ on UNIX systems and WebSphere MQ for Windows support coordination of transactions by external syncpoint managers that use the X/Open XA interface. The XA specification requires each resource manager to provide a structure called an XA Switch. This structure declares the capabilities of the resource manager, and the functions that are to be called by the syncpoint coordinator. There are two versions of this structure:
For a list of the libraries containing this structure see the WebSphere MQ System Administration Guide. Consult your transaction manager documentation to determine whether to use the static or dynamic resource management interface. The method that must be used to link them to an XA syncpoint coordinator is defined by the coordinator. Consult the documentation provided by that coordinator to determine how to enable WebSphere MQ to cooperate with your XA syncpoint coordinator. |
The subject of this X/Open specification is interface (3) in the diagram above,
|
In each thread of control, the TM must call xa_open() for each RM directly accessible by that thread before calling any other xa_ routine.
Some XA transaction managers (TXSeries) require that each XA resource manager supplies its name. This is the string called name in the XA switch structure. The resource manager for WebSphere MQ on UNIX and Windows systems is named MQSeries_XA_RMI.
Some external syncpoint coordinators (not CICS) require that each resource manager participating in a unit of work supplies its name in the name field of the XA switch structure. The WebSphere MQ resource manager name is MQSeries_XA_RMI.
Question : how do you determine in a specific installation, if MQ is the XA coordinator, or another software provides coordination ?
Looking at the verbs used in the code.
We define two scenarios for global units of work:
Question : MQ and DB must be local, or we can use Oracle remote client ?
The database server can reside on a different machine from the queue manager server, as long as the database client is installed on the same machine as the queue manager, and it supports this function. Consult the database product's documentation to determine whether their client software can be used for two-phase commit systems.
We do it in 4 steps:
An XA switch file is a shared library that defines the names of XA functions implemented in the resource manager.
On Windows, the switch libraries are precompiled and supplied in the install "%mqpath%\java\lib\jdbc".
See configuration here
On Unix, both 32-bit and 64-bit versions of the object files are supplied, located in the install path/java/lib/jdbc and install path/java/lib64/jdbc directories respectively. Makefiles to link the object files are also supplied. These use DB2_HOME and ORACLE_HOME to define where the database has been installed, which must be set appropriately.
Configuring on other platforms
A 32-bit switch library will be copied to the /var/mqm/exits directory, while a 64-bit switch library will be copied to /var/mqm/exits64.
On UNIX platforms, you must manually edit the qm.ini file. Add the following stanza to the file:
Some 64-bit transaction managers treat the long type in the XA specification as 64-bit, and some treat it as 32-bit.
WebSphere MQ supports both models.
If your transaction manager is 32-bit, or your transaction manager is 64-bit but treats the long type as 32-bit, use the switch load file
libmqmxa.a (AIX nonthreaded) or libmqmxa_r.a (AIX threaded)
If your transaction manager is 64-bit and treats the long type as 64-bit, use the switch load file
libmqmxa64.a (AIX nonthreaded) or libmqmxa64_r.a (AIX threaded)
Find them all in /usr/mqm/lib64/ !?!?!? How does linker know which one to use ???
See <mq install path>/java/lib64/jdbc/Makefile:
We modify it to Makefile.RAT:
Link using
The TM administrator can add or remove an RM from the DTP system by simply controlling the set of RMs linked to executable modules. Each RM must provide a switch that gives the TM access to the RMs xa_ routines. This lets the administrator change the set of RMs linked with an executable module without having to recompile the application.
An RM's switch uses a structure called xa_switch_t. The switch contains the RMs name, non-null pointers to the RMs entry points, a flag and a version word:
See xa.h at "\\MQ\tools\c\Samples\xatm\"
Our qm.ini is:
See XAOpenString details and syntax here
When queue manager starts, we get an error:
We do a trace and see:
Jo trobo
The Oracle XA library logs any error and tracing information to its trace file. This information is useful in supplementing the XA error codes. For example, it can indicate whether an xa_open failure is caused by an incorrect open string, failure to find the Oracle Database instance, or a logon authorization failure.
See trace file locations !
The sample source modules used to build the switch load files are:
The following transaction processing monitors (coordination through X/Open XA interface) are supported by MQ for AIX v6:
WebSphere MQ for AIX, Version 6.0 supports WebSphere Application Server as an XA coordinator. For more information about the WebSphere MQ application adaptor, see the WebSphere Application Server Enterprise Edition WebSphere MQ Application Adaptor Development Guide, SC09-4444.
A client application can participate in a unit of work that is managed by a queue manager to which it is connected. Within the unit of work, the client application can put messages to, and get messages from, the queues that are owned by that queue manager. The client application can then use the MQCMIT call to commit the unit of work or the MQBACK call to back out the unit of work. In this situation, the queue manager is acting as a transaction manager.
However, within the same unit of work, the client application cannot update the resources of another resource manager, the tables of a DB2 database, for example. This means that the queue manager can act only as a resource manager, not as a transaction manager.
Using a WebSphere MQ extended transactional client removes this restriction.
He had:
TXSeries acts as XA transaction manager for two XA resource managers: WebSphere MQ 6.0 and Oracle DBMD 10.2. We would like XA static registration for Oracle DBMS and XA dynamic registration for WebSphere MQ. The result is both Oracle and WebSphere MQ use static registration.
The switch load file is produced with this command:
The source code is "amqzscix" supplied with WebSphere MQ; this is a very trivial program:
The function contains no logic and perform this unconditioned assignment:
It seems WebSphere MQ declare itself as capable of dynamic registration.
I wrote a trivial program to inspect the content of the XA switch struct:
Compiled with this command:
The result is "3". Looking at xa.h, it means:
It should use dynamic registration, but inspecting the TXSeries console, every time an application server starts, it performs Oracle and WebSphere MQ xa_open, even if the application server starts just because you are connecting with a new terminal.
Removing Oracle definition does not change the behaviour: even if WebSphere MQ is the only XA resource manager, every time an application server starts, the xa_open, xa_recover functions are called:
Nice code : \\MQ\XA\developerWorks\XAExample\XAExample.java from developerWorks
Requires "com.ibm.db2.jcc"
The sequence of events I see is
Questions & answers :
|
|
|
|
Updated 20130401 (a)
|
|