Author |
Message
|
Girish A Rao |
Posted: Thu Aug 19, 2010 4:13 am Post subject: XA transaction using MQ .Net - getting 2012 error at Begin() |
|
|
Newbie
Joined: 19 Aug 2010 Posts: 2
|
Hi,
I am trying to put a message using MQ .Net using XA transaction in unmanged clients mode. I am getting error at Begin(), with rc 2012. I have ETC. Also, my registry is updated with the needed xa dlls. I have update the CompoentServices->Properties to have XA check box checked.
Can anyone help, why this error is coming..?
Here is the test program I am using :
namespace XASample
{
[Transaction(TransactionOption.RequiresNew)]
class XA_Try : ServicedComponent
{
static MQQueueManager mq = null;
static void Main(string[] args)
{
try
{
DoMQWork();
}
catch (Exception ex)
{
System.Console.WriteLine("Exception caught" + ex.ToString());
}
}
//Uses comitable transaction
[AutoComplete(true)]
static public void DoMQWork()
{
try
{
string qmgrName = "QM1";
System.Collections.Hashtable mqprops = new System.Collections.Hashtable();
mqprops.Add(MQC.HOST_NAME_PROPERTY, "localhost");
mqprops.Add(MQC.PORT_PROPERTY, 1414);
mqprops.Add(MQC.CHANNEL_PROPERTY, "SYSTEM.DEF.SVRCONN");
mqprops.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_XACLIENT);
mq = new MQQueueManager(qmgrName, mqprops);
TransactionOptions options = new TransactionOptions();
options.IsolationLevel = IsolationLevel.Serializable;
options.Timeout = TransactionManager.DefaultTimeout;
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew
, options
, EnterpriseServicesInteropOption.None))
{
mq.Begin();
Console.WriteLine("Connected to " + qmgrName);
MQMessage msg = new MQMessage();
msg.Expiry = 100;
MQPutMessageOptions pmo = new MQPutMessageOptions();
pmo.Options = MQC.MQPMO_SYNCPOINT;
mq.Put("A", msg, pmo);
Console.WriteLine("Put 1 message on QM with syncpoint");
}
**** some other logic *********
Thanks |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
Vitor |
Posted: Thu Aug 19, 2010 4:30 am Post subject: Re: XA transaction using MQ .Net - getting 2012 error at Beg |
|
|
![](images/avatars/905340816499abc1cdfb07.jpg) Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Girish A Rao wrote: |
Can anyone help, why this error is coming..?
|
Simplistically this is what's happening.
I'd start by checking that you're really picking up the ETC libraries, and the queue manager has been correctly configured to use the XA coordinator in question. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
markt |
Posted: Thu Aug 19, 2010 5:25 am Post subject: |
|
|
![](images/avatars/519b992c426bb0c8eac47.jpg) Knight
Joined: 14 May 2002 Posts: 504
|
The ETC enables MQ clients to be an RM under external TM control. It does not make MQ clients be a TM - which is what MQBEGIN gives. |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
Girish A Rao |
Posted: Mon Aug 23, 2010 4:02 am Post subject: |
|
|
Newbie
Joined: 19 Aug 2010 Posts: 2
|
Does that mean, If I have ETC installed, I should not issue mq.Begin()..?
If I remove the line, mq.Begin(), there are no errors. But, the message never put on the queue unless the mq.Commit() is issued.
Any inputs..?
I am tired of googling for finding a sample program for MSDTC as a transaction manager and MQ as a resource manager using .Net
Thanks |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
mqjeff |
Posted: Mon Aug 23, 2010 4:48 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
It is expected and documented behavior that a message under a transaction is not available until the transaction is committed.
It's not clear why you don't expect that behavior. |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
Vitor |
Posted: Mon Aug 23, 2010 4:52 am Post subject: |
|
|
![](images/avatars/905340816499abc1cdfb07.jpg) Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mqjeff wrote: |
It is expected and documented behavior that a message under a transaction is not available until the transaction is committed. |
To forestall your next question, this is true both if you're using XA or if you're not.
mqjeff wrote: |
It's not clear why you don't expect that behavior. |
It's sort of the point of transactionality (conceptually - think about database commits). _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
stevendonline |
Posted: Fri Oct 08, 2010 7:23 am Post subject: |
|
|
Newbie
Joined: 08 Oct 2010 Posts: 1
|
I think Girish A Rao's question is
Because MQC.MQGMO_SYNCPOINT is used, so MQMgr is spposed to enlist itself to the ambient transaction initialized by TransactionScope scope, and when scope.Complete() is called, the distributed transaction should be commit instead of calling explicitly commit on MQMgr.
Girish A Rao, did you solve your problem? anything to share? |
|
Back to top |
|
![](templates/DAJ_Glass/images/spacer.gif) |
|