Author |
Message
|
Vitor |
Posted: Wed Dec 19, 2007 5:15 am Post subject: |
|
|
 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 |
|
 |
TimothyV |
Posted: Wed Dec 19, 2007 5:32 am Post subject: |
|
|
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 |
|
 |
Vitor |
Posted: Wed Dec 19, 2007 7:28 am Post subject: |
|
|
 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 |
|
 |
David.Partridge |
Posted: Thu Dec 20, 2007 12:48 am Post subject: |
|
|
 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 |
|
 |
TimothyV |
Posted: Thu Dec 20, 2007 5:07 am Post subject: |
|
|
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 |
|
 |
David.Partridge |
Posted: Thu Dec 20, 2007 6:26 am Post subject: |
|
|
 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 |
|
 |
TheAndroid |
Posted: Thu Dec 20, 2007 8:22 am Post subject: |
|
|
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 |
|
 |
TimothyV |
Posted: Thu Dec 20, 2007 11:11 pm Post subject: |
|
|
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 |
|
 |
jefflowrey |
Posted: Fri Dec 21, 2007 3:32 am Post subject: |
|
|
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 |
|
 |
TimothyV |
Posted: Fri Dec 21, 2007 4:01 am Post subject: |
|
|
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 |
|
 |
fjb_saper |
Posted: Fri Dec 21, 2007 5:02 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 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 |
|
 |
TimothyV |
Posted: Fri Dec 21, 2007 5:25 am Post subject: |
|
|
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 |
|
 |
jefflowrey |
Posted: Fri Dec 21, 2007 5:31 am Post subject: |
|
|
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 |
|
 |
TimothyV |
Posted: Fri Dec 21, 2007 5:43 am Post subject: |
|
|
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 |
|
 |
jefflowrey |
Posted: Fri Dec 21, 2007 5:53 am Post subject: |
|
|
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 |
|
 |
|