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 » General Discussion » committing and backing out units of work

Post new topic  Reply to topic
 committing and backing out units of work « View previous topic :: View next topic » 
Author Message
vivekkooks
PostPosted: Thu Jul 03, 2003 4:30 am    Post subject: committing and backing out units of work Reply with quote

Voyager

Joined: 11 Jun 2003
Posts: 91

Hello,
I have installed MQseries on Linux/Intel.
How can I use the committing and backing out mechanism in the following test case.
I need to transfer the data from db1(eg oracle) to db2(DB2). I will be using mqseries to transfer the data. MQSeries Clients(C1 and C2) are installed on db1 and db2 systems(Linux/Intel). MQManager is installed on a different system(Linux/Intel).

db1+C1 ( installed on linux/intel)
|
|
|
MQServer(MQManager) (installed on Linux/intel)
|
|
|
db2+C2 (installed on linux/intel)

1.C1 reads the data from db1, it puts the data in mqseries. C2 gets the data(message) from mqseries. both operations are asynchronous.
2. So shall i use local unit of work(MQPUT followed by MQCMIT/MQBACK by C1 and MQGET and MQCMIT/MQBACK by C2) or global unit of work?

3. is there any sample code which shows local and global unit of work?

thanks

vivek[/img]
Back to top
View user's profile Send private message
bower5932
PostPosted: Thu Jul 03, 2003 7:25 am    Post subject: Reply with quote

Jedi Knight

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

Go out to:

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

and check out mqsync.*, mqadhoc.c, mqdb2.sqc, mqdb2log.java. They are programs that use MQ and DB2 to perform units of work. They might help some.

In your scenario, it doesn't look like you make any DB updates. This being the case, I'd go with the single phase commit of the MQ messages.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
bduncan
PostPosted: Thu Jul 03, 2003 5:00 pm    Post subject: Reply with quote

Padawan

Joined: 11 Apr 2001
Posts: 1554
Location: Silicon Valley

Also you can look in the software repository on this site (under the "repository" menu item in the nav bar above) and there are several sample programs that fit your needs...
_________________
Brandon Duncan
IBM Certified MQSeries Specialist
MQSeries.net forum moderator
Back to top
View user's profile Send private message Visit poster's website AIM Address
vivekkooks
PostPosted: Mon Jul 07, 2003 12:10 am    Post subject: Reply with quote

Voyager

Joined: 11 Jun 2003
Posts: 91

In my scenario, I am making the DB update on C2. i.e. Retrieve the data from database(db1). C1 will put the message. C2 will retrieve the message and will update the db2 database.

In this scenario should I use single phase commit as follows:
C1(MQSeries Client app):
1. get the data from database.
2. form a message.
3. put the message and if successful commit the transaction.

C2(MQSeries Client app)
1. retrieve the message.
2. update the db2.
3. if the update is successful then MQCMIT else rollback.

or should I use two phase commit as follows:
C1(MQSeries Client app):
1. MQBEGIN
2. get the data from database.
3. form a message.
4. put the message and if successful commit the transaction.

C2(MQSeries Client app)
2. MQBEGIN
1. retrieve the message.
2. update the db2.
3. if the update is successful then MQCMIT else rollback.

In two phase commit, The only difference is use of MQBEGIN, rest of the code is the same.

Can you please suggest either to use single phase commit or two phase commit in this scenario.?. Please correct me if the pseudo code is wrong...
Back to top
View user's profile Send private message
vivekkooks
PostPosted: Mon Jul 07, 2003 3:15 am    Post subject: Reply with quote

Voyager

Joined: 11 Jun 2003
Posts: 91

Also,
If the message is retrieved by C2(Mq Series Client), it performed the database updations on db2 and made commit on the database transaction.
But it may hapen that C2 crashes before committing to MQ Series.(ie commit should happen on MQSeries, in this case )

So, How to avoid this problem?. Is there any way to handle such problem.?
MQ Series Application program Guide says the following thing:
(A two-phase commit process is one in which updates that a program has
made to WebSphere MQ queues can be coordinated with updates to other
resources (for example, databases under the control of DB2®). Under such a process, updates to all resources are committed or backed out together.)

But i am unable to understand how to do this programatically. There may be multiple resources(eg. db1 in my case as Oracle and db2 in my case as DB2).

thanks,
Back to top
View user's profile Send private message
bower5932
PostPosted: Mon Jul 07, 2003 8:54 am    Post subject: Reply with quote

Jedi Knight

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

From what I see, it looks like you need a single-phase commit to read your database and put the MQ message. Since you are doing a DB read, you won't lose any data. (How do you know what to read?)

The second piece of work is the two-phase commit. You want to make sure that both the MQ message gets read and the DB update take place in the same unit of work. If something goes wrong (in the XA under the covers), you'll get notified of in-doubt transactions at restart and you'll have to decide how to resolve them.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
vivekkooks
PostPosted: Mon Jul 07, 2003 10:07 pm    Post subject: Reply with quote

Voyager

Joined: 11 Jun 2003
Posts: 91

Hello,
The MQ Series documentation says, It doesnot have transaction support for Oracle and Sybase on Linux.It only supports DB2.
Table 11. XA-compliant relational databases
MQSeries product............... DB2...........Oracle.................Sybase
MQSeries for AIX ................Yes............Yes......................Yes
MQSeries for HP-UX..............Yes............Yes..................... No
MQSeries for Linux................Yes............No..................... No
MQSeries for Sun Solaris........Yes...........Yes......................Yes
MQSeries for Windows NT
and
Windows 2000
......... Yes............. Yes...................Yes
So, How to use Two Phase Commit Mechanism for these databases(Oracle and Sybase) on Linux?.
Back to top
View user's profile Send private message
jhalstead
PostPosted: Tue Jul 08, 2003 12:51 am    Post subject: Reply with quote

Master

Joined: 16 Aug 2001
Posts: 258
Location: London

Without XA capabilities you could build some degree of integrity in to your application. Perhaps using another queue as a work in progress area.

For instance you could get from source queue, put a new message on the wip queue containing useful information for recovery - maybe the original message.
Get from source queue
Put useful data to wip queue
commit
perform DB updates and commit
get from wip queue
commit

If anything goes badly wrong in the processing it's likely that your app will shut down. When it starts up again it could go to the wip queue and use the data to determine if the db updates are complete.

This is all very closely linked in to the db data that is held and what useful field are available to query. Obviously if you are able to be a bit invasive with the db then this gets easier!

You could also create a wip table in the db, this would store the mqmd.msgid and this insert would be commited along with the "real" db updates. Now you can easily work out where you are at after either a db, mq or hw failure!


Anyway - just a few thoughts

Jamie
Back to top
View user's profile Send private message Send e-mail
jefflowrey
PostPosted: Tue Jul 08, 2003 5:43 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

It would likely be easier and faster, if one has to reinvent XA, to browse the original message and then later do a destructive read, instead of doing two destructive reads and one persistant put. Although this way you can't necessarily use the backout count for retry management.
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 » General Discussion » committing and backing out units of work
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.