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 » Multiphase Commit » Global and Single unit of work

Post new topic  Reply to topic
 Global and Single unit of work « View previous topic :: View next topic » 
Author Message
solomon_13000
PostPosted: Fri Jul 18, 2008 5:28 am    Post subject: Global and Single unit of work Reply with quote

Master

Joined: 13 Jun 2008
Posts: 284

Does a global unit of work mean that commit and rollback is done on more than one resource manager where else in a single unit of work the commit and rollback is done on a single resource manager?.

My example for a single unit of work would be for an application to put a message on a queue. The database server will pick up this message and make the changes on the database. If something goes wrong during the update a rollback is done. In regards to a global unit of work, we can have two database and the commit and rollback will be done on both database. From the example I can say that MQ can function as a transaction manager.

In a banking environment, which transaction represents a single unit of work and global unit of work?.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Jul 18, 2008 7:16 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

No it just means that if you are not carefull and do not separate correctly your transaction it (global transaction) will override your transaction settings and force you to a rollback because you may not be able to do multiphase commit....

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
solomon_13000
PostPosted: Fri Jul 18, 2008 6:35 pm    Post subject: Reply with quote

Master

Joined: 13 Jun 2008
Posts: 284

MQ can function as a transaction manager. Now the transaction manager will coordinate the global unit work. So under the transaction manager we have a global unit of work. Under the global unit of work we have the resource manager which is the participant of the global unit of work. So the resource manager can include our database. Referring to the internet the definition of a transaction is refered to as the completion of a task.

So im assuming that in a global unit of work a single transaction can update database 1 and database 2. The transaction will first write on database 1. If it is successful, the success message will be put on a queue and send it to the receiving queue using a sender channel. Otherwise if the transaction is not successful it will rollback. The receiving end will get the message on the receiving queue and write it on database 2. Is my understanding about global unit of work correct?.

Also as I was reading the manuals it is stated that an application can only participate in a single unit of work. If it participate in another single unit of work the MQBEGIN will raise an exception error. So is this why MQ is allowed to function a transaction manager so that it can perform a global unit of work?.
Back to top
View user's profile Send private message
Bill.Matthews
PostPosted: Sat Jul 19, 2008 8:08 am    Post subject: Reply with quote

Master

Joined: 23 Sep 2003
Posts: 232
Location: IBM (Retired)

Simple Answer: No. Your assumptions are not correct.

Longer Answer:

I am going to use a different set of terms to describe a "Single Unit of Work" and a "Global Unit of Work" - and these are "Single Phase Commit" and "Two Phase Commit".

With a Single Phase Commit (i.e. Single Unit of Work), when the application has reached a "commit" or "rollback" point then that functional command is sent to the Resource Owner (as a COMMIT or ROLLBACK) request. This is done via the resource's interface, for example - an inter-process call. Should there be more than one resource involved then each resource will commit or rollback its own changes without regard to any other resource. Thus, one could have a situation where one of more resources are committed but others fail to commit.

This is not a good situation.

Because of this possibility, the Two Phase Commit function was implemented by the various resource managers. The basic premise of the Two Phase Commit (i.e. Global Unit of Work - and, in the distributed environment - this is called XA) is that an overall Resource Manager is required.

The role of the Resource Manager in terms of the Commit or Rollback process is as follows: The application, who must inform the Resource Manager via a "BEGIN" request that a Two Phase is requested, will also inform the Resource Manager via a COMMIT, for example, or a successful competition that all updates have been made. The Resource Manager must then issue a "Prepare to Commit" request to every Resource owner. The Resource Manager then waits until each resource owner has insured that all updated information is hardened to disk and also that all information necessary to remove such information is also ready (and safe).

Once the Resource Manager has received a "Ready to Commit" from all resource owners then the second phase is started and a Commit is issued. If one (or more) resource owners issue a "Failed" status, then the Resource Manager tells all resource owners to "Rollback".

With the XA implementation by the various database managers, another component involved is called an XASwitch file. If that is not provided (and there are a few other implementation items) then there is no Global Unit of Work.

Please do not assume that a Global Unit of Work allows updates that occur across physical systems to be coordinated. That is not true. Thus, some implementations include what is described as "Compensation" - this is an extra capability where an original copy is retained in case of a failure by another component. However, that is a totally different topic for discussion.

One more point - when an application has started a Unit of Work and it also wants to do an MQPut - that request is not completed until the unit of work is also completed.

Thus, in your assumption:

Quote:
So im assuming that in a global unit of work a single transaction can update database 1 and database 2. The transaction will first write on database 1. If it is successful, the success message will be put on a queue and send it to the receiving queue using a sender channel. Otherwise if the transaction is not successful it will rollback. The receiving end will get the message on the receiving queue and write it on database 2. Is my understanding about global unit of work correct?.


I have to say that your assumptions are not correct.

You could be describing a possible implementation of Compensation. But here the sending application also has more responsibilities and work to be done. It is not automatic - and such an implementation is NOT a Global Unit of Work.
_________________
Bill Matthews
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sat Jul 19, 2008 12:16 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

In addition to the excellent expose Bill has done, let's also have a look at using WebSphere (WAS) as J2EE Transaction Manager (TM).

Here we talk as well about a global unit of work and a "local unit of work".
Units of work delimitation is typically done in the EJBean descriptor.

Now when the method is flagged as transaction required it is automatically enrolled into any existing transaction at the point of invocation. Should none exist one is created. This superseeds any coding flag set in the session creation... So by default you are always participating in a global transaction.

You can deny participation in a transaction by setting the flag to not supported in the deployment descriptor.

Standards for MDBs however would call for an independent transaction flagging the method as requires new.

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
solomon_13000
PostPosted: Sat Jul 19, 2008 5:51 pm    Post subject: Reply with quote

Master

Joined: 13 Jun 2008
Posts: 284

Single phase commit - Single unit of work

Application sends a (COMMIT or ROLLBACK) request to the Resource owner VIA resource interface. If more than one resources are involved then each resource will (COMMIT or ROLLBACK) independently. So some of the resources will get commited but others may fail.

Two phase commit - Global unit of work

Application request a two phase commit to the Resource manager using a BEGIN request. The Application also sends a COMMIT request to the the Resource manager to inform a successful update as an example. The Resource manager will send a COMMIT request to every Resource owner to COMMIT. If the Resource owner issues a failed status, then the Resource manager will tell the Resource owner to ROLLBACK.

So a two phase commit is used to overcome the problems of a one phase commit. So for a two phase commit to happen the resources must be XA complient?. Otherwise the resources cannot participate in a global unit of work? What is the overall Resource manager known as?. Is it known as XA Resource manager?
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sat Jul 19, 2008 9:27 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

The overall resource manager is known as the TM (Transaction Manager)
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
solomon_13000
PostPosted: Sat Jul 19, 2008 9:36 pm    Post subject: Reply with quote

Master

Joined: 13 Jun 2008
Posts: 284

So the Resource owner would be the Queue Manager?. Resources would be the queues, distribution list and so on?.
Back to top
View user's profile Send private message
Bill.Matthews
PostPosted: Mon Jul 21, 2008 4:49 am    Post subject: Reply with quote

Master

Joined: 23 Sep 2003
Posts: 232
Location: IBM (Retired)

solomon_13000 wrote:
So the Resource owner would be the Queue Manager?. Resources would be the queues, distribution list and so on?.


MQ is a Resource owner (and may be a resource manager). Since its actions are taken on behalf of a specific Queue Manager, then you could think of the Queue Manager as the Resource Owner. Resources are just queues. A Distribution List points to multiple queues, so the DL is really not the resource.

DB2, Oracle, etc are also Resource Owners. A specific instance of DB2 (etc) may "own" multiple databases.

So, in an XA environment you could have a MQ based application updating multiple databases and getting and putting multiple messages to multiple queues owned by a single Queue Manager ... and have a Global Unit of Work that covers everything.

This concept is very important in the financial (banking) industry. Consider a transaction that receives a request to transfer money. It first "extracts" the money from the first account and then adds the money to the second account. It then provides a confirmation msg. The customer would not be happy if the money were taken out but the addition step failed.

One last comment - when designing XA applications, especially when there are multiple databases involved, it is important to also have a database administrator involved.
_________________
Bill Matthews
Back to top
View user's profile Send private message
bruce2359
PostPosted: Mon Jul 21, 2008 5:53 am    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9403
Location: US: west coast, almost. Otherwise, enroute.

A local unit of work is one in which only the resources of the qmgr are comitted (MQCMIT) or backed out (MQBACK) by the application program.

A global unit of work in one in which resources of multiple resource managers (like MQ and DB2) are comitted (MQCMIT) or backed out (MQBACK) by the application. The application (midrange platforms) uses MQBEGIN to state its intention to be the coordinator of a global unit of work.

An external transaction manager (like Bea Tuxedo, WAS, TXSeries) may be used to coordinate the unit of work. The external coordinator may provide its own api calls (like SRRBACK and SRRCMIT on z/OS).
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
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 » Multiphase Commit » Global and Single unit 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.