Forums » Enduro/X development »
tpcommit() is not doing commit for IBM mq message.
Added by Muralidhara 6 days ago
Hello
tpcommit() is not committing the IBM MQ message though it says commit is successful. Attached the logs for tpopen() and tpbegin()/tpcommit() logs.
Below is the flow of our clientApp code:
int main(){
if (tpinit(NULL) -1) {
std::cerr << "Failed to initialize Enduro/X Client: " << tpstrerror(tperrno) << std::endl;
return -1;
}
if (tpopen() -1) {
std::cerr << "Failed to open Resource Managers via XA::::: " << tpstrerror(tperrno) << std::endl;
tpterm();
return -1;
}
MQCONNX(MQ_Host, &connOpt, HCon, &CompCode, Reason);
while(1) {
if(tpbegin(5, 0)) {
std::cerr << "Failed to tpbegin ::::: " << tpstrerror(tperrno) << std::endl;
tpterm();
return -1;
}
std::cout << "Successfully began XA 2 trns" << std::endl;
MQMD md = {MQMD_DEFAULT}; /* Message Descriptor /
MQPMO pmo = {MQPMO_DEFAULT}; / put message options
pmo.Options = MQPMO_SYNCPOINT MQPMO_DEFAULT_CONTEXT;
md.Report = MQRO_EXPIRATION_WITH_DATA;
MQPUT(HCon, HObj, &md,&pmo,msglen,msg,&CompCode,Reason);
if(tpcommit(0)) {
std::cerr << "Failed to tpcommit ::::: " << tpstrerror(tperrno) << std::endl;
tpterm();
return -1;
}
}
MQCLOSE(HCon,&HObj,C_options, &CompCode, Reason);
if(tpclose()) {
std::cerr << "Failed to tpclose ::::: " << tpstrerror(tperrno) << std::endl;
tpterm();
return -1;
}
tpterm();
}
app.ini content for IBM RM:
NDRX_CCTAG=MQ_TAG
[@global/MQ_TAG]
NDRX_XA_RES_ID=1
NDRX_XA_OPEN_STR=QMNAME=MN2345
NDRX_XA_CLOSE_STR=$NDRX_XA_OPEN_STR
NDRX_XA_DRIVERLIB=/usr/lib64/libndrxxawsmqs.so
NDRX_XA_RMLIB=/opt/mqm/lib64/libmqmxa64_r.so
NDRX_XA_LAZY_INIT=0
ndrxconfig.xml contents for IBM RM:
<server name="tmsrv">
<min>3</min>
<max>3</max>
<srvid>40</srvid>
<cctag>MQ_TAG</cctag>
<rmname>MQSeries_XA_RMI</rmname>
<sysopt>-e ${NDRX_ULOG}/tmsrv-rm1.log r - -t1 -l${NDRX_APPHOME}/tmlogs/rm1</sysopt>
</server>
- This is Enduro/X stock resource manager definition file
- Append as needed.
- format is: <rm_name(logical)>:<xa_switch_name>:<compiler_flags e.g. libs and paths> #
- Oracle static registration switch:
#
Oracle_XA:xaosw:-L${ORACLE_HOME}/lib -lclntsh
MQSeries_XA_RMI:MQRMIXASwitch:-L/opt/mqm/lib64 -lmqmxa64_r -lmqm_r
Replies (10)
RE: tpcommit() is not doing commit for IBM mq message. - Added by Madars 6 days ago
Hi,
1) Can you please attach tmsrv-rm1.log?
2) Can you please attach full log file of clientApp? As looking on PIDs tpopen.txt was from other PID not the one in enduro_tpbegin_tpcommit.txt .
Did you start the clientApp with proper NDRX_CCTAG="MQ_TAG" ./clientApp env?
3) Do you have access to IBM MQ logs? Are there any useful infos?
Thanks
RE: tpcommit() is not doing commit for IBM mq message. - Added by Madars 6 days ago
+
ndrxconfig.xml does not use "<rmname>MQSeries_XA_RMI</rmname>" this tag.
Tmsrv loads the XA switch provided by shared library.
RE: tpcommit() is not doing commit for IBM mq message. - Added by Muralidhara 5 days ago
Hello,
Below is the answer for all your queries.
1) Can you please attach tmsrv-rm1.log?
Attached complete tmsrv-rm1.log.
2) Can you please attach full log file of clientApp? As looking on PIDs tpopen.txt was from other PID not the one in enduro_tpbegin_tpcommit.txt .
Attached full log file.
3)Did you start the clientApp with proper NDRX_CCTAG="MQ_TAG" ./clientApp env?
Yes. You can cross check the same in the logs attached.
4) Do you have access to IBM MQ logs? Are there any useful infos?
Yes, We have access, but there is no useful information.
5)ndrxconfig.xml does not use "<rmname>MQSeries_XA_RMI</rmname>" this tag.
Tmsrv loads the XA switch provided by shared library.
Yes, This was not required, included just to check. Anyhow we have removed it.
RE: tpcommit() is not doing commit for IBM mq message. - Added by Madars 5 days ago
Hi,
maybe you can try with
NDRX_XA_RMLIB=/opt/mqm/lib64/libmqcxa64_r.so
+ rebuild the binary with MQSeries_XA_RMI of update mqcxa64_r too.
Thanks
RE: tpcommit() is not doing commit for IBM mq message. - Added by Muralidhara 5 days ago
Hello,
maybe you can try with
NDRX_XA_RMLIB=/opt/mqm/lib64/libmqcxa64_r.so
OK.
+ rebuild the binary with MQSeries_XA_RMI of update mqcxa64_r too.
Rebuild our client app with MQSeries_XA_RMI switch? can you provide an example? using buildclient or buildserver?
RE: tpcommit() is not doing commit for IBM mq message. - Added by Madars 5 days ago
Rebuild our client app with MQSeries_XA_RMI switch? can you provide an example? using buildclient or buildserver?
If you did not use buildclient or buildserver, but built binary directly, then there is no need to use these tools.
The client app compiled/linked in standard way should work. Just remember that you link your program mqcxa64_r.
Basically library linked with client app and library specified in NDRX_XA_RMLIB should match.
RE: tpcommit() is not doing commit for IBM mq message. - Added by Muralidhara 4 days ago
Hello,
Thanks. it is working if we link the libmqcxa64_r.so. But it is expected to work with libmqmxa64_r.so also, any specific reason not working with libmqmxa64_r.so ?
Also, In the same client application we are updating the oracle database and committing with oracle command, but instead we want use the same XID which is used for the IBM MQ and commit using the same tpcommit(),
How we can achieve it? because when we can do the tpopen() only for one at time, either IBM MQ or Oracle.
RE: tpcommit() is not doing commit for IBM mq message. - Added by Madars 4 days ago
Thanks. it is working if we link the libmqcxa64_r.so. But it is expected to work with libmqmxa64_r.so also, any specific reason not working with libmqmxa64_r.so ?
libmqmxa64_r.so is used for Server/local bindings — the transaction manager and application connect to a queue manager installed on the same machine. So if your client app + endurox is on different machine, then libmqcxa64_r.so shall be used.
Also, In the same client application we are updating the oracle database and committing with oracle command, but instead we want use the same XID which is used for the IBM MQ and commit using the same tpcommit(),
Pls check #138 solution.
However, Enduro/X use different XIDs for each of the RMs/Databases even when committing records in single global transaction. There are common XID parts identifying the global txn, but per DB xid includes own RMID for example. This typically does not cause any issues for applications.
What is reason why you need exactly the same XID between resources?
RE: tpcommit() is not doing commit for IBM mq message. - Added by Muralidhara 3 days ago
Hello,
What is reason why you need exactly the same XID between resources?
Please check your below comment from "https://www.endurox.org/boards/2/topics/131" , that is reason I used same XID term.
You can use one resource manager with "client1" (say IBM MQ) and create "server1" process to interact with Oracle DB. The if you do tpcall or tpconnect from client1 to server1 (and exchange with data between these processes), these data/changes of RMs (MQ/ORADB) both will pass under the same XID. When client process has global txn open, and it connects to server process, the server process would automatically be joined in that original client transaction.
Pls check #138 solution.
You are refering to "https://www.endurox.org/boards/2/topics/131" ?
RE: tpcommit() is not doing commit for IBM mq message. - Added by Madars 3 days ago
As said, the global transaction will commit in multiple resources. Physical XID may differ resources, but there are common part identifying the global transaction. If you need it for some reason, you can parse it manually. However, not sure for what purpose you need this, as global transaction still works. Full coordination of commit is done by Enduro/X anyway over the resources, and normally the developer do not do direct work with the XID. Here is the code how XID is built: http://www.silodev.com/lxr/ident?_i=atmi_xa_get_branch_xid for particular RM.
(1-10/10)
