<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>All About Interop : Transactions</title><link>http://blogs.msdn.com/dotnetinterop/archive/tags/Transactions/default.aspx</link><description>Tags: Transactions</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Setting up WinXPSP2 or WS2003 for XA transactions with MQ</title><link>http://blogs.msdn.com/dotnetinterop/archive/2005/07/06/setting-up-winxpsp2-for-xa-transactions-with-mq.aspx</link><pubDate>Wed, 06 Jul 2005 21:14:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:436065</guid><dc:creator>DotNetInterop</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/dotnetinterop/comments/436065.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dotnetinterop/commentrss.aspx?PostID=436065</wfw:commentRss><description>&lt;FONT face=Tahoma size=2&gt;
&lt;P&gt;In a &lt;A href="http://blogs.msdn.com/dotnetinterop/archive/2005/07/06/435864.aspx" mce_href="http://blogs.msdn.com/dotnetinterop/archive/2005/07/06/435864.aspx"&gt;previous post&lt;/A&gt;, I talked about transactions without components, spanning MQ and SQL Server. The hardest part in doing that was setting up the environment. For posterity, here's what I did: &lt;/P&gt;
&lt;P&gt;Steps: &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;install Windows XPSP2 or WS2003&lt;/LI&gt;
&lt;LI&gt;install the MQ Client or Server software. &lt;/LI&gt;
&lt;LI&gt;install the &lt;A href="http://www-306.ibm.com/software/integration/wmq/transclient.html" mce_href="http://www-306.ibm.com/software/integration/wmq/transclient.html"&gt;MQ XA Client (aka "MQ Extended Transactional Client")&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;install the &lt;A href="http://www-306.ibm.com/software/integration/mqfamily/support/summary/" mce_href="http://www-306.ibm.com/software/integration/mqfamily/support/summary/"&gt;latest fixpack for WMQ&lt;/A&gt;. For Windows v5.3, As of May 2005, this is CSD10. &lt;/LI&gt;
&lt;LI&gt;register the XA DLL in the registry. &lt;BR&gt;&lt;BR&gt;for MQ, &lt;A href="http://www-1.ibm.com/support/docview.wss?rs=171&amp;amp;context=SSFKSJ&amp;amp;q1=XA+DTC&amp;amp;uid=swg21159392&amp;amp;loc=en_US&amp;amp;cs=utf-8?=en" mce_href="http://www-1.ibm.com/support/docview.wss?rs=171&amp;amp;context=SSFKSJ&amp;amp;q1=XA+DTC&amp;amp;uid=swg21159392&amp;amp;loc=en_US&amp;amp;cs=utf-8?=en"&gt;according to IBM&lt;/A&gt;, the DLL is &lt;B&gt;&amp;lt;MQDIR&amp;gt;\bin\amqmtsxatm.dll &lt;/B&gt;but on a MQ client-only machine, it may be &lt;B&gt;&amp;lt;MQDIR&amp;gt;\bin\amqmtsxatmc.dll&lt;/B&gt; &lt;BR&gt;&lt;BR&gt;For MQ then, it is: &lt;BR&gt;[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSDTC\XADLL]&lt;BR&gt;Key name: amqmtsxatm.dll &lt;BR&gt;Data: C:\progra~1\ibm\MQ\bin\amqmtsxatm.dll&lt;BR&gt;&lt;/LI&gt;&lt;BR&gt;
&lt;LI&gt;If you are running the app from an MQ client node, get the interim fix from IBM; I don't know which fix this is. you have to request it. It is not included in CSD10. It may be included in CSD11. If you are running the app on a MQ server node, then you do not need the interim fix. &lt;/LI&gt;
&lt;LI&gt;Turn on DTC in Windows. This is slightly different on XPSP2 and WS2003. On XPSP2, it is like this: &lt;BR&gt;Control Panel--&amp;gt; Admin Tools --&amp;gt; Component Services --&amp;gt; My Computer --&amp;gt; Properties &lt;BR&gt;&lt;BR&gt;select the MS DTC tab, click the "Security Configuration..." button. &lt;BR&gt;Check the "Network DTC Access..." box. &lt;BR&gt;Check the XA box. &lt;/LI&gt;&lt;BR&gt;
&lt;LI&gt;allow the "network service" user to read the directory in which the XA DLL resides. &lt;BR&gt;&lt;BR&gt;Use Explorer for this. For my install of MQ, this directory is &lt;BR&gt;c:\progra~1\ibm\mq\bin\ &lt;/LI&gt;
&lt;LI&gt;add "network service" user to the MQM group (or other group authorized to "perform XA recovery" on MQ). &lt;/LI&gt;
&lt;LI&gt;set the NMQ_MQ_LIB variable to c:\progra~1\ibm\mq\bin\mqic32xa.dll. This is from the "Using .NET" doc.) &lt;/LI&gt;
&lt;LI&gt;Run the app&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;That's it. &lt;/P&gt;&lt;SPAN style="COLOR: red; FONT-STYLE: italic"&gt;
&lt;P&gt;[addendum, 13 October 2008:&amp;nbsp; An attentive reader has pointed out that &lt;/P&gt;&lt;FONT face=Consolas size=3&gt;the WebSphere MQ Solutions in a Microsoft .Net Environment (SG24-7012-00) states:&lt;/FONT&gt; 
&lt;P&gt;&lt;FONT face=Consolas size=3&gt;“WebSphere MQ applications can participate in transactions managed by Microsoft transaction managers. The application either has to be directly connected to a queue manager, or it has to use the extended transactional client function when running on a remote machine.”&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;So my assertion above, that you need the Extended Transactional Client, may not be appropriate in all cases. When in doubt, prefer the IBM documentation. Better yet, contact IBM for full details. I'm not even sure the Extended client still exists for MQ V6.0 and beyond. &lt;/P&gt;&lt;/SPAN&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=436065" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/Interop/default.aspx">Interop</category><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/MQ/default.aspx">MQ</category><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/Transactions/default.aspx">Transactions</category></item><item><title>Transactions, SwC, and IBM MQSeries</title><link>http://blogs.msdn.com/dotnetinterop/archive/2005/07/06/transactions-swc-and-ibm-mqseries.aspx</link><pubDate>Wed, 06 Jul 2005 18:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:435864</guid><dc:creator>DotNetInterop</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/dotnetinterop/comments/435864.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dotnetinterop/commentrss.aspx?PostID=435864</wfw:commentRss><description>&lt;FONT face=Tahoma size=2&gt;
&lt;P&gt;In .NET 2.0 (code-named "Whidbey"), Microsoft is introducing a bunch of slick enhancements and extensions to the programming model for transactions. Much of this is available through the new System.Transactions namespace. There's a whitepaper, &lt;A href="http://www.theserverside.net/news/thread.tss?thread_id=33220" mce_href="http://www.theserverside.net/news/thread.tss?thread_id=33220"&gt;Introduction to System.Transactions&lt;/A&gt;, available since April. &lt;/P&gt;
&lt;P&gt;One of the nice things about Whidbey is the introduction of the TransactionScope class into the .NET Framework. This gives developers another option in programming their transactional work. A code snippet from that whitepaper shows the model I am talking about: &lt;/P&gt;&lt;/FONT&gt;
&lt;DIV class=cf&gt;
&lt;P class=cl&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;SPAN class=cb1&gt;using&lt;/SPAN&gt;(TransactionScope scope = &lt;SPAN class=cb1&gt;new&lt;/SPAN&gt; TransactionScope()) {&lt;/P&gt;
&lt;P class=cl&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;SPAN class=cb2&gt;/* Perform transactional work here */&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=cl&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;SPAN class=cb2&gt;//No errors - commit transaction&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=cl&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scope.Complete();&lt;/P&gt;
&lt;P class=cl&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;/DIV&gt;&lt;FONT face=Tahoma size=2&gt;
&lt;P&gt;For those of you who have been around for 10+ years, it looks very much like &lt;A href="http://publib.boulder.ibm.com/infocenter/txen/topic/com.ibm.txseries510.doc/aetgpt0028.htm#HDRDEVCLIENTS" mce_href="http://publib.boulder.ibm.com/infocenter/txen/topic/com.ibm.txseries510.doc/aetgpt0028.htm#HDRDEVCLIENTS"&gt;Tran-C or Tran-C++, from Transarc's Encina&lt;/A&gt; (Graeme Dixon, the father of Tran-C, is now a distinguished engineer at IBM. Transarc was acquired by IBM in 1994). &lt;/P&gt;
&lt;P&gt;It's a nice advance for .NET developers, and System.Transactions will bring other benefits, too. Some nice optimizations for one-phase commits, for example. But actually, you can get a similar the using(ts= new TransactionScope()){ } programming model with .NET v1.1.&amp;nbsp; The code looks essentially the same : &lt;/P&gt;&lt;/FONT&gt;
&lt;DIV class=cf&gt;
&lt;P class=cl&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;SPAN class=cb1&gt;using&lt;/SPAN&gt;( TxUtil.ESTransactionScope ts = &lt;SPAN class=cb1&gt;new&lt;/SPAN&gt; TxUtil.ESTransactionScope()) {&lt;/P&gt;
&lt;P class=cl&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class=cb2&gt;// do transactional work...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=cl&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ts.VoteToCommit = &lt;SPAN class=cb1&gt;true&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P class=cl&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;/DIV&gt;&lt;FONT face=Tahoma size=2&gt;
&lt;P&gt;Now, some disclaimers: for .NET v1.1, this is not "built-in" to the framework, which means you, the apps programmer, have to provide and maintain the code for the TransactionScope class. Also, it depends on COM+ stuff that is available only in Windows Server 2003, and Windows XP SP2, so if you use Windows 2000, you can't get this. &lt;/P&gt;
&lt;P&gt;But on the supported platforms, the code required to implement it yourself is pretty trivial, and &lt;A href="http://blogs.msdn.com/florinlazar/archive/2004/07/24.aspx" mce_href="http://blogs.msdn.com/florinlazar/archive/2004/07/24.aspx"&gt;examples&lt;/A&gt; &lt;A href="http://www.dotnetjunkies.com/Article/17955D1E-411C-41FD-89A1-37B2ED986D6A.dcik" mce_href="http://www.dotnetjunkies.com/Article/17955D1E-411C-41FD-89A1-37B2ED986D6A.dcik"&gt;abound&lt;/A&gt;. It has been called &lt;A href="http://msdn.microsoft.com/library/en-us/cossdk/html/da93d164-234a-4d1e-b82c-f3f904bb8cb6.asp" mce_href="http://msdn.microsoft.com/library/en-us/cossdk/html/da93d164-234a-4d1e-b82c-f3f904bb8cb6.asp"&gt;"Services without components"&lt;/A&gt;, and the doc on MSDN mostly focuses on C/C++ developers, but it is also easily employed by .NET v1.1 devs using VB or C#. &lt;/P&gt;
&lt;P&gt;A while back, Microsoft used this sort of programming model in a benchmark, and &lt;A href="http://websphere.sys-con.com/read/46828.htm" mce_href="http://websphere.sys-con.com/read/46828.htm"&gt;IBM had claimed that this was a really advanced technique:&lt;/A&gt; &lt;EM&gt;"To decide to code the distributed transactions with ServiceDomain classes ... shows a deep amount of technical skill."&lt;/EM&gt; But it's not true. It's actually simpler than using ServicedComponents, in my book. Using the ServiceDomain class in .NET V1.1 is pretty straightforward. You can use transactions without deriving from the ServicedComponent class, and without configuring that component in the COM+ catalog. In short, it makes the high-performance Windows transaction engine more easily accessible to more programmers, and that's good. &lt;/P&gt;
&lt;H3&gt;Umm, Interop?&lt;/H3&gt;
&lt;P&gt;Yes, so the SwC programming model is nice, and it gets nicer in .NET 2.0 (aka "Whidbey"). The obvious next question here is, what about interop with non-Microsoft transactional resources? If you've been reading other entries on this blog you won't be surprised to learn that &lt;EM&gt;it just works&lt;/EM&gt;. The SwC programming model does not introduce a new transaction engine. It is merely a new programming interface on the built-in platform transaction engine, formerly known as COM+. So, what works with the "traditional" COM+ programming model also works with SwC. &lt;/P&gt;
&lt;P&gt;A great example is IBM MQSeries. In financial services enterprises, MQ is near-ubiquitous. It seems to be the preferred mechanism for linking anything to mainframe systems. And there are numerous programming interfaces for MQ - including C/C++, COBOL, RPG, Java, and, since September 2003, a .NET assembly. IBM introduced "the MQ Classes for .NET" as a new feature in MQ v5.3 CSD05, at that time. That allowed any .NET app to connect to MQ in a pretty simple manner. IBM did the integration with COM+, so an app that connects to MQ and another transactional resource manager, for example, MS SQL Server, can perform updates across both of them as a single logical unit of work, with ACID guarantees. The canonical example is, dequeue a message, then update a database based on the content of that message. &lt;/P&gt;
&lt;P&gt;For an MQ app using the .NET classes from IBM, the MQ client library will automatically enlist in a transaction created programmatically via System.EnterpriseServices.ServiceDomain.Enter(). The doc in the IBM Redbook, &lt;A href="http://www.redbooks.ibm.com/abstracts/sg247012.html" mce_href="http://www.redbooks.ibm.com/abstracts/sg247012.html"&gt;WebSphere MQ Solutions in a Microsoft .Net Environment (SG24-7012-00)&lt;/A&gt; discusses transactions via COM+ configured components, but does not mention SwC. I am here to tell ya, when you access MQ, the same transactional guarantees are available whether you use traditional COM+ interfaces or SwC. &lt;/P&gt;
&lt;P&gt;It's really pretty simple. Within the transactional work, you need to ask for syncpoints on the Get() or Put(), eg gmo.Options|= MQC.MQGMO_SYNCPOINT, or pmo.Options|= MQC.MQPMO_SYNCPOINT. The hardest part for me was installing and configuring Windows XP SP2 and MQ to allow XA transactions. I have a &lt;A href="http://blogs.msdn.com/dotnetinterop/archive/2005/07/06/436065.aspx" mce_href="http://blogs.msdn.com/dotnetinterop/archive/2005/07/06/436065.aspx"&gt;separate post&lt;/A&gt; for that. &lt;/P&gt;
&lt;P&gt;I packaged up a sample, including source code, for you to try. For comparison purposes, I also included a sample that shows transactions spanning MSMQ and SQL Server, using the same programming model. (Like MQ, MSMQ also automatically enlists in ambient transactions.) Enjoy, and let me know what you think! &lt;/P&gt;
&lt;P&gt;&lt;A href="http://cheeso.members.winisp.net/dl/Swc-MSMQ-MQ-2005july05.zip" mce_href="http://cheeso.members.winisp.net/dl/Swc-MSMQ-MQ-2005july05.zip"&gt;download the sample code&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;-Dino&lt;/P&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=435864" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/Interop/default.aspx">Interop</category><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/MQ/default.aspx">MQ</category><category domain="http://blogs.msdn.com/dotnetinterop/archive/tags/Transactions/default.aspx">Transactions</category></item></channel></rss>