Author |
Message
|
pmane |
Posted: Tue Oct 30, 2001 10:50 pm Post subject: |
|
|
Acolyte
Joined: 17 Oct 2001 Posts: 50
|
I want to pick a message from a queue and put it in a db in single transaction. Is it ture that I need a Web-sphere application server to do that. Can't I use MQ.begin() . Can MQ work as transaction manager ? |
|
Back to top |
|
 |
UpkarSharma |
Posted: Wed Oct 31, 2001 12:35 am Post subject: |
|
|
Apprentice
Joined: 15 Aug 2001 Posts: 27 Location: Mumbai
|
1. Retrieving message from a queue and putting in db in a single transaction is very simple.
Get message from the queue and put it in database and if some exception occurrs, use backout() method of MQQueueManager class. This will maintain that data is not lost.
2. For Two Phase transaction, you need one coordinator and other participants. MQSeries can act both as Coordinator and participants.
But MQSeries as coordinator is supported only on certain platforms. On other platforms u will need a transaction manager, which will coordinate Two Phase commit.
[ This Message was edited by: UpkarSharma on 2001-10-31 00:45 ] |
|
Back to top |
|
 |
UpkarSharma |
Posted: Wed Oct 31, 2001 12:43 am Post subject: |
|
|
Apprentice
Joined: 15 Aug 2001 Posts: 27 Location: Mumbai
|
MQ.begin() will be used only if u are performing some functions on the messages. In that case u will put all the actions in a Unit of work and that unit is either committed or backed out. But these calls MQBEGIN, MQCMIT, MQBACK , are supported only on certain platforms. |
|
Back to top |
|
 |
middlewareonline |
Posted: Wed Oct 31, 2001 8:21 am Post subject: |
|
|
Acolyte
Joined: 09 Jul 2001 Posts: 73
|
There are two ways of doing this
1. XA
Setup Queue Manager to be XA coordinator. You will have to enable XA on the datbase you are using (Oracle, SYbase, DB2...NO Microsoft directly but possible through MTS).
Now, in the code you will get handle for db connection through Queue Mangager connect call. You will make future SQL call on this connection (don't do explicit db connect/disconnect). Use MQBEGIN, MQBACK and MQCMIT for UOV.
2. Write a sophasticated logical code in your program, which will take care of 99% situations, if the DB and Queue Manager is running on the same box. The possiblity of failure increases, if they are on distributed system.
Chris
MiddlewareOnline.COM |
|
Back to top |
|
 |
pmane |
Posted: Wed Oct 31, 2001 6:55 pm Post subject: |
|
|
Acolyte
Joined: 17 Oct 2001 Posts: 50
|
I tried to do the same thing . Below is my code
COM.ibm.db2.jdbc.DB2XADataSource ds = new COM.ibm.db2.jdbc.DB2XADataSource();
ds.setDatabaseName("sample");
Connection con = qMgr.getJDBCConnection( ds );
qMgr.begin();
MQPutMessageOptions pmo = new MQPutMessageOptions(); // accept the // defaults,
pmo.options = MQC.MQPMO_SET_IDENTITY_CONTEXT | MQC.MQPMO_SYNCPOINT ;
system_default_local_queue.put(hello_world,pmo);
qMgr.commit();
system_default_local_queue.close();
// Disconnect from the queue manager
qMgr.disconnect();
This gives me error as
MQJE001 : Completion code 1, Reason 2372
When I use mqrc I do not get any info about this.
What is wrong ? the code fails at the line qMgr.begin().
[ This Message was edited by: pmane on 2001-10-31 18:58 ] |
|
Back to top |
|
 |
EddieA |
Posted: Thu Nov 01, 2001 7:45 am Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
|
Back to top |
|
 |
middlewareonline |
Posted: Thu Nov 01, 2001 10:57 am Post subject: |
|
|
Acolyte
Joined: 09 Jul 2001 Posts: 73
|
Are you sure the call fails at qmgr.begin() and not on previous line where you try to get a connection. Check the DB2 setup for XA. Enable XA trace to see whether Queue Manager is able to open the connection with DB2 or NOT ?
MiddlewareOnlince.com |
|
Back to top |
|
 |
arnabkundu |
Posted: Wed Dec 19, 2001 4:00 am Post subject: |
|
|
Newbie
Joined: 25 Sep 2001 Posts: 3
|
How do I enable XA Trace because I am getting error when i call getJDBCConnection(datasource) in MQQueueManager
[ This Message was edited by: arnabkundu on 2001-12-19 04:01 ] |
|
Back to top |
|
 |
|