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 » 2- phase commit possible?

Post new topic  Reply to topic Goto page Previous  1, 2, 3  Next
 2- phase commit possible? « View previous topic :: View next topic » 
Author Message
Vitor
PostPosted: Wed Dec 19, 2007 5:15 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

TimothyV wrote:
Now how must this be configured for MSDTC ?


According to your site standards, individual requirements, preferences and other software (databases in your case) requirements.

Hey, it's your system.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
TimothyV
PostPosted: Wed Dec 19, 2007 5:32 am    Post subject: Reply with quote

Novice

Joined: 17 Dec 2007
Posts: 17

Now this is fun:

Scenario 2: Other software provides the coordination

http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/index.jsp?topic=/com.ibm.mq.amqzag.doc/fa13980_.htm

For detailed information on using COM+, including how to configure it, and how to develop your applications and object code, read the WebSphere MQ COM+ Component Services Support part of the WebSphere contact admin Center.

only problem is, i have version 5.3, and nothing there is mentioned like this....

why is information put in the help center, and not online? damn
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Dec 19, 2007 7:28 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

TimothyV wrote:
only problem is, i have version 5.3

...

why is information put in the help center, and not online?


Because v5.3 is out of support?

You should upgrade. Not just for documentation reasons.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
David.Partridge
PostPosted: Thu Dec 20, 2007 12:48 am    Post subject: Reply with quote

Master

Joined: 28 Jun 2001
Posts: 249

It appears that you may be leaking a queue manager connection at the very least which is bad news.

I see no sign of an _mqQmgr.begin() call ... which you will need if you intend the QMGR to control (coordinate) the UOW. If you are using (e.g.) the DBM to control this, then you need to use its APIs to tell it that the UOW is starting.

Obviously you need to be connected to the queue manager to be able to issue the _mqQmgr.begin() call, but I'm pretty sure that if you are using the DBM to coordinate that you need to be connected to the QMGR before you start the UOW using its APIs.

Finally when all is done you issue the commit using either the MQQueueManager.commit() method if using MQ to coordinate, or the call necessary to commit in the coordinating software.
_________________
Cheers,
David C. Partridge
Back to top
View user's profile Send private message
TimothyV
PostPosted: Thu Dec 20, 2007 5:07 am    Post subject: Reply with quote

Novice

Joined: 17 Dec 2007
Posts: 17

David, i do not want the QMGR to coordinate the transaction.

At the moment i start this code in the serviced component, a transaction is already started, because i first do some stuff in different databases. this current transaction is coordinated by the MSDTC.

Now from within this transactionscope i run the code from this Com+ component. Now instead of inlisting, the QMGR starts a second transaction to do his work, instead of inlisting. Somehow i have to tell the QMGR it has to enlist, and not coordinate a new transaction.
Back to top
View user's profile Send private message
David.Partridge
PostPosted: Thu Dec 20, 2007 6:26 am    Post subject: Reply with quote

Master

Joined: 28 Jun 2001
Posts: 249

Then, as I said in my earlier post, I believe that you must create the qmgr object BEFORE you start the transaction, otherwise I don't believe it can participate. In the the code you showed, you were creating the QM object at the time you want to put the message.
_________________
Cheers,
David C. Partridge
Back to top
View user's profile Send private message
TheAndroid
PostPosted: Thu Dec 20, 2007 8:22 am    Post subject: Reply with quote

Novice

Joined: 04 Dec 2007
Posts: 23

I don't believe the QMGR connection has to exist before the transaction starts. This can be delayed.
However to allow it to participate late, the transaction coordinator (MSDTC in your case) must be configured to build a connection to the specific QMGR which will be used in the transaction. This is done by nominating it in the OpenString ala QMNAME=<QMGRName>
MQ has an very strict rule that if you delay MQ participation, the MQCONN call must go to the same QMGR as nominated by the Transaction Manager OpenString. Trying to "override" the nomination will result in an error.
However, if you call MQCONN before starting the transaction, MQ (on the Transaction Manager) will use the inplace connection and ignore the OpenString parameter. This is way more flexible and that is why it is considered good practice.
Back to top
View user's profile Send private message
TimothyV
PostPosted: Thu Dec 20, 2007 11:11 pm    Post subject: Reply with quote

Novice

Joined: 17 Dec 2007
Posts: 17

I changed my code like this:

1) i create the queue manager

Code:
  System.Collections.Hashtable properties = new System.Collections.Hashtable();
                properties.Add(MQC.TRANSPORT_PROPERTY, IBM.WMQ.MQC.TRANSPORT_MQSERIES);

                  MQQueueManager _mqQmgr = new MQQueueManager("qm_amqtsivt", properties);


2) i start a new Transaction scope, and in this new scope i execute 2 database actions (db.Do()) and one mq action (mq.Do(...)).

Code:
using (System.Transactions.TransactionScope sc = new System.Transactions.TransactionScope(TransactionScopeOption.RequiresNew,new TimeSpan(0,10,0)))
                {
                    db.Do();
                    db.Do();
                    mq.Do(_mqQmgr);
                    sc.Complete();
                }


So i pass my queue manager to my com+ component. In the com+ component i use this queuemanager to put messages on the queue.

Code:
[Transaction(TransactionOption.Required)]
    public class CUSTOM_MQ : ServicedComponent
    {
       

        public CUSTOM_MQ()
        {
           
        }

        [AutoComplete]
        public void Put(MQQueueManager _mqQmgr)
        {

            MQMessage mqMsg = null;
            MQQueue mqQueue = null;

            try
            {
                MQPutMessageOptions opt = new MQPutMessageOptions();
                opt.Options |= IBM.WMQ.MQC.MQPMO_SYNCPOINT;
               
                mqQueue = _mqQmgr.AccessQueue("TestQueueTimothy", MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT);

                mqMsg = new MQMessage();
                mqMsg.Format = IBM.WMQ.MQC.MQFMT_STRING;
                mqMsg.WriteString(DateTime.Now.ToString("HH:mm:ss"));
                mqQueue.Put(mqMsg, opt);

                mqQueue.Close();
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (mqQueue != null && mqQueue.IsOpen)
                    mqQueue.Close();
            }

        }

 
    }


What happens now is that there is only one com+ transaction, so that's a good thing. But the actions that go to the queue manager are still not enlisting in the transaction. Normally when i execute this line of code:

sc.Complete();

the transaction scope is committed. This means the transaction is succesfull and the message should be put on the queue, but that does not happen.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Fri Dec 21, 2007 3:32 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

You need to use MQBegin and MQCommit/MQRollback, when using 2pc.

You almost certainly want to open/access the queue outside your Put loop, so that you only open it once and only close it once. For performance and resource reasons.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
TimothyV
PostPosted: Fri Dec 21, 2007 4:01 am    Post subject: Reply with quote

Novice

Joined: 17 Dec 2007
Posts: 17

jefflowrey wrote:
You need to use MQBegin and MQCommit/MQRollback, when using 2pc.



I added a _mqQmgr.begin() before the accessqueue line, now i get a {"MQRC_HCONN_ERROR"} error.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Dec 21, 2007 5:02 am    Post subject: Reply with quote

Grand High Poobah

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

TimothyV wrote:
jefflowrey wrote:
You need to use MQBegin and MQCommit/MQRollback, when using 2pc.



I added a _mqQmgr.begin() before the accessqueue line, now i get a {"MQRC_HCONN_ERROR"} error.


Why before the accessqueue line?
I would have expected it to be before the loop i.e. before the first put.
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
TimothyV
PostPosted: Fri Dec 21, 2007 5:25 am    Post subject: Reply with quote

Novice

Joined: 17 Dec 2007
Posts: 17

Quote:

I would have expected it to be before the loop i.e. before the first put.


where are you guys seeing a loop? there is no loop
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Fri Dec 21, 2007 5:31 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

TimothyV wrote:
where are you guys seeing a loop? there is no loop


I guess we're assuming that your program is going to put more than one message during it's lifespan, and you aren't going to be starting it up every time you need to put a single message, and then starting it up again when you need to put the next message....
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
TimothyV
PostPosted: Fri Dec 21, 2007 5:43 am    Post subject: Reply with quote

Novice

Joined: 17 Dec 2007
Posts: 17

jefflowrey wrote:
TimothyV wrote:
where are you guys seeing a loop? there is no loop


I guess we're assuming that your program is going to put more than one message during it's lifespan, and you aren't going to be starting it up every time you need to put a single message, and then starting it up again when you need to put the next message....


hehe ok. That's probably what will happen, but now i just want my sample app to work. Don't have to put this in my project when this simple app doesn't work.

By the way where i put that begin method, always getting that exception. Are you sure you need this method to use a 2pc where MSDTC is the coordinator?
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Fri Dec 21, 2007 5:53 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

TimothyV wrote:
By the way where i put that begin method, always getting that exception. Are you sure you need this method to use a 2pc where MSDTC is the coordinator?


In fact, I'm entirely wrong about that.

The section in the contact admin installed locally on my machine about MQ Programming under COM+ says that you explicitly shouldn't use these.

Quote:
WebSphere MQ operations within COM+ Component Services objects
Use the syncpoint option on your GETs and PUTs, that is:
MQGET with MQGMO_SYNCPOINT or MQGMO_SYNCPOINT_IF_PERSISTENT
MQPUT with MQPMO_SYNCPOINT.
Do not use MQCMIT or MQBACK (because COM+ Component Services/DTC is in charge of the transaction).
Do not use MQBEGIN (WebSphere MQ cannot act as coordinator when COM+ Component Services/DTC is).


I'm not sure what the effect of closing the queue with the transaction uncommitted is.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page Previous  1, 2, 3  Next Page 2 of 3

MQSeries.net Forum Index » Multiphase Commit » 2- phase commit possible?
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.