ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » sample code for 2 phase commit

Post new topic  Reply to topic
 sample code for 2 phase commit « View previous topic :: View next topic » 
Author Message
shantha
PostPosted: Tue Apr 27, 2004 5:42 am    Post subject: sample code for 2 phase commit Reply with quote

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
View user's profile Send private message
mqonnet
PostPosted: Tue Apr 27, 2004 6:59 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
bower5932
PostPosted: Tue Apr 27, 2004 6:59 am    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

There is a mqdb2log.java program at:

http://www.developer.ibm.com/tech/sampmq.html

It does a put rather than a get, but it should give you a feel for what you are trying to do.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
shantha
PostPosted: Wed Apr 28, 2004 5:59 am    Post subject: Reply with quote

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
View user's profile Send private message
bower5932
PostPosted: Wed Apr 28, 2004 6:21 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
techno
PostPosted: Thu Apr 29, 2004 7:42 am    Post subject: Reply with quote

Chevalier

Joined: 22 Jan 2003
Posts: 429

Did you try running mqdb2log.java ?
Back to top
View user's profile Send private message
shantha
PostPosted: Thu Apr 29, 2004 8:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
pshan81
PostPosted: Sun Mar 12, 2006 10:48 pm    Post subject: two phase commit Reply with quote

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
View user's profile Send private message
BenR
PostPosted: Mon Mar 13, 2006 6:25 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
jefflowrey
PostPosted: Mon Mar 13, 2006 7:05 am    Post subject: Reply with quote

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
View user's profile Send private message
BenR
PostPosted: Mon Mar 13, 2006 7:32 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
jefflowrey
PostPosted: Mon Mar 13, 2006 10:55 am    Post subject: Reply with quote

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
View user's profile Send private message
pshan81
PostPosted: Tue Mar 14, 2006 12:14 am    Post subject: two phase commit Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » sample code for 2 phase commit
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.