Enterprise Services

1. Where to use Enterprise Services

Enterprise Services is a scalable technology, using component load balancing technology, you can distribute the load of customers on different systems. Component load balancing technology requires Microsoft Application Center Server. For more information on Microsoft Application Center Server, please refer to http://www.microsoft.com/applicationcenter . Enterprise Services can also be used on the client system because the technology is included in Windows Xp .

 

1, the environment

The basic function of Enterprise Services is to provide an environment (context) that can intercept method calls and perform a certain service function before calling the desired method. The .net Remoting environment also plays an important role in Enterprise Services, because these environments are used to intercept .net objects configured with Enterprise Services. However, because the com component can be configured in Enterprise Services in a similar way to the .net component, com+ The environment and the .net Remoting environment coexist, so that the com component and the .net component can participate in the same transaction processing.

 

2. Automatic transaction processing

The most commonly used feature of Enterprise Services is automatic transaction processing. Using this feature, you do not need to start and execute transaction processing in the code, but you can apply attributes to a class. Use [Transaction] attributes and options Required, Supported, RiquiresNew , NotSupported, you can mark a class as requiring related transaction processing. If you mark the attribute with the option Required, a transaction processing will be automatically created at the beginning of the method, and the transaction processing will be submitted or stopped when the root component of the transaction processing is completed .

 

When developing a complex object model, this declarative method of the program has special advantages compared with manual transaction processing. For example, suppose there is a Person object and several Address and Document objects related to the Person object. Storing the Person object and all related objects in a transaction, and performing transaction processing programmatically means that a transaction object is transferred to all related objects so that they can participate in the same transaction and use the transaction explicitly Processing, there is no need to transfer the transaction object, because this will be done in the background through the environment.

 

3. Distributed transaction processing

Enterprise Services not only provides automatic transaction processing, transaction processing can also be distributed in multiple databases. Enterprise Services transaction processing is supported by DTC. DTC supports databases that use XA protocol. XA protocol is a two-stage implementation protocol. SQL Server and Oracle support, single transaction processing can write data to SQL Server and Oracle database.

Distributed transaction processing is not only useful for databases, but a single transaction can also write data to the database and message queue. If one of these two operations fails, the other operation will roll back.

 

4. Object pool

Enterprise Services provides object pool features. These services use thread pools to respond to customer requests. Object pools can be used to initialize objects that take a long time to initialize. After using object pools, objects will be created in advance, so customers don’t need to wait for the objects to be initialized. .

 

5. Role-based security

Using role-based security, you can clearly define roles and define which methods or components can be used in which roles. The system administrator assigns these roles to users or user groups. In the program, there is no need to deal with access control lists, but you can Use roles that are just simple strings.

 

6. Queued components

The queued component is an abstract layer of the message queue. The client does not transfer the message to the message queue, but calls the method through a logger. The method provided by the logger is the same as the .net class configured in Enterprise Services. The record The server is creating messages and sending them to the server application through the message queue. If the client application is running in a disconnected environment, or the request sent to the server needs to be cached before being sent to another server, you can use queuing Components and message queues.

 

7. Loosely coupled events

Events are used in .net Remoting and events are used in the com environment. Through these two event mechanisms, a firm connection will be established between the client and the server. This is different from loosely coupled events (LCE). In LCE, com+ functions It will be inserted between the client and the server. The publisher will register an event with com+ through an event class. Instead of sending the event directly to the client, the publisher will send the event to the event class registered with the LCE service. The LCE service forwards the event to the subscriber, which is a client application that has registered a subscription for the event.

 

8. Service without components

The service without components is a new feature of com+1.5. With this service, you can create an environment without configuring components. Use some classes in the System.EnterpriseServices namespace. The environment can be created in a method. The environment can be required by some transaction processing to automatically process transactions managed by DTC

 

Second, transaction processing

For example, when ordering books online, the book ordering process will take the book that the customer wants from the warehouse, place it in the customer's order box, and then charge the customer's credit card for the purchase of the book. Both actions are either successfully completed or Not complete, this is the role of transaction processing.

Transaction processing has some special requirements. For example, transaction processing must have a valid state. If the server is powered off, it also needs to have a valid state. The characteristics of transaction processing can be defined by the term ACID.

 

1. ACID attributes

Atomicity: Represents a unit of work. In transaction processing, either the entire unit of work is successfully completed or not.

Consistency: After performing transaction processing, the state of the database must be valid and consistent.

Isolation: Indicates that concurrent transaction processing is independent of state changes. When the transaction processing is not completed, transaction A cannot see the changed state in transaction B.

Durability: After the transaction is completed, it must be stored in a durable way. If the power is turned off or the server crashes, these states must be restored when restarted.

 

2. Attributes of transaction processing

Service components can be marked with the [Transaction] attribute to define whether the component needs transaction processing and how to perform transaction processing

 

 

3. The result of transaction processing

Setting the environment consistent and done bits will affect transaction processing. If the consistent bit is set to true, it means that the component is satisfied with the result of the transaction. If all the components involved in the transaction are successful, the transaction is completed. If the consistent bit is set If false, the component is not satisfied with the result of the transaction processing. When the root object that started the transaction processing is completed, the transaction processing will be aborted. If the done bit is set, the object can be released after the method call is completed, and the next method call can be used Create a new instance.

In .net, you can also apply the attribute [AutoComplete] to the method to set the consistent and done bits instead of calling the ContextUtil method. Using this attribute, if the method succeeds, the ContextUtil.SetComplete() method is automatically called. If the method fails, And throw an exception, call the ContextUtil.SetAbort() method through the property [AutoComplete].

 

 

Guess you like

Origin blog.csdn.net/jinzhengquanqq/article/details/5876330