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 » XA transaction using MQ .Net - getting 2012 error at Begin()

Post new topic  Reply to topic
 XA transaction using MQ .Net - getting 2012 error at Begin() « View previous topic :: View next topic » 
Author Message
Girish A Rao
PostPosted: Thu Aug 19, 2010 4:13 am    Post subject: XA transaction using MQ .Net - getting 2012 error at Begin() Reply with quote

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
View user's profile Send private message
Vitor
PostPosted: Thu Aug 19, 2010 4:30 am    Post subject: Re: XA transaction using MQ .Net - getting 2012 error at Beg Reply with quote

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
View user's profile Send private message
markt
PostPosted: Thu Aug 19, 2010 5:25 am    Post subject: Reply with quote

Knight

Joined: 14 May 2002
Posts: 502

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
View user's profile Send private message
Girish A Rao
PostPosted: Mon Aug 23, 2010 4:02 am    Post subject: Reply with quote

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
View user's profile Send private message
mqjeff
PostPosted: Mon Aug 23, 2010 4:48 am    Post subject: Reply with quote

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
View user's profile Send private message
Vitor
PostPosted: Mon Aug 23, 2010 4:52 am    Post subject: Reply with quote

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
View user's profile Send private message
stevendonline
PostPosted: Fri Oct 08, 2010 7:23 am    Post subject: Reply with quote

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
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 » XA transaction using MQ .Net - getting 2012 error at Begin()
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.