Forums » Enduro/X development »
Different Resource managers(oracle and IBM MQ)
Added by Muralidhara 17 days ago
Below snippet is from tpopen() description fromenudrox documentation, it says we can have multiple resource managers for our application:
If your application needs different resource managers or different transaction branches, then you can use environment variable override functionality, see ex_envover(5) and ndrxconfig.xml(5)
In our client application we are doing commit for IBM MQ and oracle database, but we want to use enudroX 2 phase commit and commit the IBM MQ changes and oracle database changes using the endurox's tpcommit() with single XID.
How to achieve this? Below is our app.ini changes and ndxrconfig.xml changes. We are starting our application from terminal with "$NDRX_CCTAG=MQ_TAG/ORA_TAG ./client1" or "$NDRX_CCTAG=ORA_TAG/MQ_TAG ./client1" , when we do this it is loading either IBM mq lib or oracle lib.
How to load both RM libs and have single XID for our transaction?
app.ini:
[@global/MQ_TAG]
NDRX_XA_RES_ID=1
NDRX_XA_OPEN_STR=QMNAME=MNDBV
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=1
- Remove external double quotes and add the mandatory DB descriptor token
NDRX_XA_RES_ID=2
NDRX_XA_DRIVERLIB=/usr/lib64/libndrxxaoras.so
NDRX_XA_RMLIB=/oracle/product/19.28_client/lib/libclntsh.so
NDRX_XA_OPEN_STR=ORACLE_XA+SqlNet=158.234.207.204:1521/hot199perf+ACC=P/MNPRDDUMPMAY/banana12+SesTM=180+Threads=true
NDRX_XA_CLOSE_STR=ORACLE_XA+SqlNet=158.234.207.204:1521/hot199perf+ACC=P/MNPRDDUMPMAY/banana12+SesTM=180+Threads=true
NDRX_XA_LAZY_INIT=1
ENV:ORACLE_HOME=/oracle/product/19.28_client
ENV:LD_LIBRARY_PATH=/opt/mqm/lib64:/oracle/product/19.28_client/lib:/home/nagaraju/lib:/usr/lib64
ndrxconfig.xml:
<server name="tmsrv">
<min>3</min>
<max>3</max>
<srvid>40</srvid>
<cctag>MQ_TAG</cctag>
<sysopt>-e ${NDRX_ULOG}/tmsrv-rm1.log r - t1 -l${NDRX_APPHOME}/tmlogs/rm1</sysopt> -t4 -l${NDRX_APPHOME}/tmlogs/ora</sysopt>
</server>
<server name="tmsrv">
<min>3</min>
<max>3</max>
<srvid>50</srvid>
<cctag>ORA_TAG</cctag>
<sysopt>-e ${NDRX_ULOG}/tmsrv-ora.log -r -
</server>
Replies (10)
RE: Different Resource managers(oracle and IBM MQ) - Added by Madars 17 days ago
Hi Muralidhara,
Welcome to Enduro/X forum.
To do interaction with two different Resource Managers, you need to use two processes. One XATMI process can operate only with one particular kind of Resource Manager.
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.
Then in the end, if client1 do tpcommit(), then both MQ and Oracle changes would be committed together.
In such case you need to configure two tmsrv, where one has cctag of MQ_TAG and other tmsrv with ORA_TAG.
Then client1 you start with NDRX_CCTAG=MQ_TAG, but server1 you configure in ndrxconfig.xml with <cctag> set to <ORA_TAG>.
Let me know, more if more help needed.
RE: Different Resource managers(oracle and IBM MQ) - Added by Muralidhara 17 days ago
I have configured two tmsrv only, one for IBM MQ and one for oracle(ORA_TAG), Please carefully take a look at my app.ini and ndrxconfig.xml changes.
Also I didn't understand why we need to create server1 to interact with oracle DB? because all our business logic is in client application code, where we put the message to IBM queue and update the oracle database tables, then we do MQ commit and DB commit. We don't want to move this business logic outside of this.
app.ini:
[@global/MQ_TAG]
NDRX_XA_RES_ID=1
NDRX_XA_OPEN_STR=QMNAME=MNDBV
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=1
[@global/ORA_TAG]
NDRX_XA_RES_ID=2
NDRX_XA_DRIVERLIB=/usr/lib64/libndrxxaoras.so
NDRX_XA_RMLIB=/oracle/product/19.28_client/lib/libclntsh.so
NDRX_XA_OPEN_STR=ORACLE_XA+SqlNet=158.234.207.204:1521/hot199perf+ACC=P/MNPRDDUMPMAY/banana12+SesTM=180+Threads=true
NDRX_XA_CLOSE_STR=ORACLE_XA+SqlNet=158.234.207.204:1521/hot199perf+ACC=P/MNPRDDUMPMAY/banana12+SesTM=180+Threads=true
NDRX_XA_LAZY_INIT=1
ENV:ORACLE_HOME=/oracle/product/19.28_client
ENV:LD_LIBRARY_PATH=/opt/mqm/lib64:/oracle/product/19.28_client/lib:/home/nagaraju/lib:/usr/lib64
ndrxconfig.xml:
<server name="tmsrv">
<min>3</min>
<max>3</max>
<srvid>40</srvid>
<cctag>MQ_TAG</cctag>
<sysopt>-e ${NDRX_ULOG}/tmsrv-rm1.log r - t1 -l${NDRX_APPHOME}/tmlogs/rm1</sysopt>
</server>
<server name="tmsrv">
<min>3</min>
<max>3</max>
<srvid>50</srvid>
<cctag>ORA_TAG</cctag>
<sysopt>-e ${NDRX_ULOG}/tmsrv-ora.log -r - -t4 -l${NDRX_APPHOME}/tmlogs/ora</sysopt>
</server>
RE: Different Resource managers(oracle and IBM MQ) - Added by Madars 17 days ago
Also I didn't understand why we need to create server1 to interact with oracle DB?
Currently this is not supported by Enduro/X. However, multiple xa switches support per binary is planned for future releases.
RE: Different Resource managers(oracle and IBM MQ) - Added by Muralidhara 17 days ago
Thanks for the confirmation.
Can you please explain how we can interact with 2 different resource manager with current enduroX release?
Can you explain more on previous statement *"To do interaction with two different Resource Managers, you need to use two processes. One XATMI process can operate only with one particular kind of Resource Manager." *
How we can achieve this?
RE: Different Resource managers(oracle and IBM MQ) - Added by Muralidhara 17 days ago
Thanks for the confirmation.
Can you please explain how we can interact with 2 different resource manager with current enduroX release?
Can you explain more on your previous statement:
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.
How we can achieve this? Can you please explain in detail?
RE: Different Resource managers(oracle and IBM MQ) - Added by Madars 11 days ago
Hi Muralidhara,
Please find sample app attached (demo_app.zip).
It demonstrates the approach of doing batch transfer in single XA transaction from TMQ and PostgreSQL database.
src/qtransfer uses tpconnect/tpsend - conversation mode to handle transfer in single txn
src/qtransfer2 uses tpcall() API handle transfers in single txn
correspondingly src/pgwritesv xatmi server provides two services - "PGWRITE" for batch conversational data receive and insert into DB under single global txn. And "PGWRITE2" inserts one record at call used by tpcall(), but here also those many calls would fall under single global transaction.
TMQ and PostgreSQL database are just two resources to demonstrate how to operate with them. You can use similar principle for IBM MQ -> Oracle transfers.
(demo_app.zip attached)
Thanks
demo_app.zip (28.6 KB)
RE: Different Resource managers(oracle and IBM MQ) - Added by Madars 11 days ago
Attached slightly simplified version of src/qtransfer (tpconnect/tpsend) + and simplified PGWRITE service code.
demo_app2.zip (30.8 KB)
RE: Different Resource managers(oracle and IBM MQ) - Added by Muralidhara 5 days ago
Hello,
Thanks. Will try to make the similar changes for IBM MQ and oracle DB and see if it works.
RE: Different Resource managers(oracle and IBM MQ) - Added by Muralidhara 2 days ago
Hello,
Went through the demo_app2.zip attached,
For our requirement we can conside only "*src/pgwritesv*" & "*src/qtransfer2*" and we can ignore "*src/qtransfer/*" & "*src/qgen/*" ??
What we understood is we can make IBM MQ related changes similar to src/qtransfer2 and use tpcall() to src/pgwritesv to make oracle DB related changes.
Please confirm whether our understanding is correct or not.
RE: Different Resource managers(oracle and IBM MQ) - Added by Madars 2 days ago
What we understood is we can make IBM MQ related changes similar to src/qtransfer2 and use tpcall() to src/pgwritesv to make oracle DB related changes.
Please confirm whether our understanding is correct or not.
Yes, correct. And in pgwritesv only see "PGWRITE2" service, and ignore "PGWRITE".
Thanks
(1-10/10)