Distributed Transactions

xiaoxiao2021-03-06  42

(Transfer from Saucer) In business development, a problem that is often encountered is to do distributed transactions. Generally recommended practices are made to be servicedComponent, reference

Transaction ControlWriting Serviced Components

This approach has several problems that the components and the dependent components must be strong-named, in the usual case (such as web application), we need to manually register components. But then, if we change the components, you need to stop the service, log out of the component, and then re-register the component. In addition, this Transaction is Declarative and Automatic, which cannot be used to accurately control Transaction, and Declaration is at the level of class and cannot be transaction in the method level. The reason is that ServicedComponent is based on the early COM service architecture, and Transactional Context is closely coupled to Object (object).

However, in a few years ago, the COM 1.5 (Windows 2003 server also supported) has been launched, and Transactional Context can greatly simplify Transactional Programming independently of Object (object). The 2002 MSDN magazine introduced the associated API (COENTERSERVICEDOMAIN / COLEAVICVICEDOMAIN) by COM expert Tim Ewald and provided C # Wrapper.

Discover Powerful Low-Level Programming In Windows XP with New Com APIS

In .NET 1.1, the same function is implemented by 2 classes, System.EnterpriseServices.ServiceDomain with System.EnterpriseServices.ServiceConfig.

Here is the example of Don Box on the blog of July 12, July 12,

ServiceConfig CONFIG = NewServiceConfig (); config.Transaction = TransactionOption.Required; serviceDomain.enter (); serviceDomain.Leave (); serviceDomain.leave ();

In .NET 2.0, according to DON, you can do this

Using (Transactionscope Scope = newTransactions) {mytxcode (); scope.constent = true;

Please refer to

Using Distributed Transactions in .NET 1.x without deeriving from servicedcomponent

转载请注明原文地址:https://www.9cbs.com/read-73072.html

New Post(0)