+

Search Tips | Advanced Search

Distributed transactions in managed mode

IBM MQ .NET classes use System.Transactions namespace for the distributed transactions support in managed mode. In the managed mode, MS DTC coordinates and manages distributed transactions across all the servers enlisted in a transaction.

IBM MQ .NET classes provide an explicit programming model based on the System.Transactions.Transaction class and an implicit programming model using the System.Transactions.TransactionScope, class where the transactions are automatically managed by the infrastructure.

Using (TransactionScope scope = new TransactionScope ())
{
	Q.Put (putMsg,pmo);
	scope.Complete ();
}

Q.close();
qMgr.Disconect();}

MQQueueManager qMgr = new MQQueuemanager ("MQQM);
MQQueue Q = QMGR.AccessQueue("Q", MQC.MQOO_OUTPUT+MQC.MQOO_INPUT_SHARED);
MQPutMessageOptions pmo = new MQPutMessageOptions();
pmo.Options = MQC.MQPMO_SYNCPOINT;
MQMessage putMsg1 = new MQMessage();
Using(CommittableTransaction tx = new CommittableTransaction()){
Transaction.Current = tx;
	try
	{
	Q.Put(MSG,pmo);
	tx.commit();
	}
	catch(Exception)
	{tx.rollback();}
	}
	
Q.close();
qMgr.Disconnect();
}