Author |
Message
|
shantha |
Posted: Tue Apr 27, 2004 5:42 am Post subject: sample code for 2 phase commit |
|
|
Apprentice
Joined: 11 Dec 2003 Posts: 41
|
Hi all,
I will explain my sceneriao first.
I have a trigger monitor running which keeps monitoring a queue.
when ever there is a message in a queue,the trigger monitor triggers a java program,which
1 fetches the message,
2 puts it to a folder
3 parses it,since it is an XML message
4 and updates the oracle database(differnt tabels based on differnt conditions).
Now my problem is,even if it encounters any problem,either while putting the message to the folder either while accessing the database or,while updating the database,the message should be put back into the queue.
and according to my understanding,this is 2 phase commit.
CAn any one please give me the sample code and sugget as to how can I acheive this.
Thanks in advance |
|
Back to top |
|
 |
mqonnet |
Posted: Tue Apr 27, 2004 6:59 am Post subject: |
|
|
 Grand Master
Joined: 18 Feb 2002 Posts: 1114 Location: Boston, Ma, Usa.
|
Not sure if anybody can give you the code, as you have to figure that out by yourself.
But you could look in the manuals, app programming guide to be more precise. It has answers to *all* your questions.
Also *look* in the samples/tools directory and you would find a load of samples. AMQSXAG0 is a C app that might be of interest.
MQbegin/mqcmit/mqback in the app porg ref would also help.
Cheers
Kumar |
|
Back to top |
|
 |
bower5932 |
Posted: Tue Apr 27, 2004 6:59 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
|
Back to top |
|
 |
shantha |
Posted: Wed Apr 28, 2004 5:59 am Post subject: |
|
|
Apprentice
Joined: 11 Dec 2003 Posts: 41
|
HI,Thanks for the reply.
But when I use mqmr.begin() I get mqexception with error code 2012.
CAn any one please give me a sample code,for just a 2 phase commit,between the MQ and database.It will be of great help
thanks in advance
Shantha |
|
Back to top |
|
 |
bower5932 |
Posted: Wed Apr 28, 2004 6:21 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
If you are looking at mqdb2log.java, it is sample code for a two-phase commit between MQ and a database. I'm guessing that you have something else that isn't set right in your configuration. Are you connecting in bindings mode or client? You need to be in bindings. Have you made all of the necessary qmgr ini changes as documented in the System Administration manual? What about your switch file? I believe that there are also changes that need to be made to the database. |
|
Back to top |
|
 |
techno |
Posted: Thu Apr 29, 2004 7:42 am Post subject: |
|
|
Chevalier
Joined: 22 Jan 2003 Posts: 429
|
Did you try running mqdb2log.java ? |
|
Back to top |
|
 |
shantha |
Posted: Thu Apr 29, 2004 8:34 pm Post subject: |
|
|
Apprentice
Joined: 11 Dec 2003 Posts: 41
|
HI THanks for the help.
I used qMgr .commit at the end of my program
and used qMgr.backout at every exception like MQEXception,SQLException,ioexception,NullPOinterexception.
So my problem is solved.I did not use qMgr.commit.
And my message is in syncpoint at the beginning
Thanks again for the help
regards
Shantha |
|
Back to top |
|
 |
pshan81 |
Posted: Sun Mar 12, 2006 10:48 pm Post subject: two phase commit |
|
|
Acolyte
Joined: 24 May 2005 Posts: 72
|
Santha,
I am also getting 2012 error in my twophasecommit.My MQ,db and application are running in separate machines.
Could you tell me how you resolved that? |
|
Back to top |
|
 |
BenR |
Posted: Mon Mar 13, 2006 6:25 am Post subject: |
|
|
Acolyte
Joined: 31 Jan 2006 Posts: 60 Location: Hursley, UK
|
Separate machines? Are you using client transport? MQBEGIN needs your application to be running on the same machine as the queue manager, using Bindings transport. |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Mar 13, 2006 7:05 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
To expand a bit on what BenR said.
If you require two-phase commit between MQ and a database, then you must run your code either using a Bindings connection (which requires your application to be on the same machine as the MQ queue manager), or you must purchase and use the WebSphere MQ Extended Transactional Client, and then run it on the machine where your application runs.
The kicker is that the ETC is licensed at the same cost as a queue manager. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
BenR |
Posted: Mon Mar 13, 2006 7:32 am Post subject: |
|
|
Acolyte
Joined: 31 Jan 2006 Posts: 60 Location: Hursley, UK
|
I'd assumed that MQ was transaction manager here, if so then the application needs to be on the same box, MQBEGIN will throw an environment error (2012) if it is called in client mode (even if the ETC is present).
If something else (e.g. an application server) is transaction manager, then things are slightly different - the ETC may be used. |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Mar 13, 2006 10:55 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
So, what you're saying is that I can not re-deploy the same standalone application on a machine that has the ETC instead of MQServer?
I have to change my code? That seems fairly un-useful.
I'd thought the whole point of the ETC was that it would act as a Transaction Manager in the same way as the MQServer does. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
pshan81 |
Posted: Tue Mar 14, 2006 12:14 am Post subject: two phase commit |
|
|
Acolyte
Joined: 24 May 2005 Posts: 72
|
Thanks a lot jefflowrey,shantha.
I am getting 2012 error in the following scenario
1.when MQ,application and DB are running in separate machines
2.MQ and application are running in the same machine(binding mode) and Db in a diiferent machine
According to your answer for the second case(binding mode) twophase commit should work.But i am getting 2012 error.Any suggestions? |
|
Back to top |
|
 |
|