First, the question of the proposed: (Listed below I encountered the problem)
1, each request of end user, will read mapping file--can be solved by caching;
2, the XXX subsystem needs to write mapping files--can also be written to memory and then bulk write file to solve;
Second, the analysis solves the problem:
Since there are 2 or more subsystems that need to read and write to the same file, and the client has great concurrency, there is a high likelihood of read-write conflicts or errors, which will also affect the performance of the system.
Read and write files by invoking common out-of-process components, and this common out-of-process component will only load the contents of the file into memory when it is started, and update the memory when the file changes.
Introduction of COM + components:
COM + has been generated as early as the window2000 release and is integrated into the operating system and is in the form of a service at run time. COM + adds a series of MTS (a system service that manages persistent data in a database and also handles persistent Message Queuing and file system services in a transaction):
1, transaction services: It ensures the integrity of the data in the distributed system.
2. Security services: Its security model provides a way to handle security without writing any code.
3. Synchronous services: Provides a way to manage concurrency problems in components without writing code.
4, Resource management: (including Resource manager and resource allocator) Manage database connection, network connection and memory, etc.
5, JIT activation: That is (Just in time) is inherited from MTS, a service, when a client calls to keep an instance of the object active and cached in server memory, when the object is used, the MTS environment is notified that the resource occupied by the object can be freed, such as a database connection.
6, Object pool: To provide a line pool store ready-made objects for the next reuse, is a system of an automatic service. When an application accesses a COM + component, an instance of the component is created for the application and stored in the object pool, the application shuts down to destroy the instance, and the component is free to configure the state of its instance in the pool, enabling the reuse of the instance and increasing the performance and scalability of the application.
7, role-based Security: This is easy to understand, that is, verify the role, give a security license, to different users to different permissions.
8. Queue component (MSMQ): Provides asynchronous Message Queuing, which can automatically convert data into packets in its form.
9. Shared Property Manager (SPM): Used to manage object state information stored in memory, which can be used to share the state between multiple objects and provide concurrent processing within a server process.
10. Compensation Resource Manager (CRM): Used to generate log files during transaction processing and to handle system crashes. Including CRM worker (is the main part of CRM, the interface provided by the infrastructure of the CRM writes the information about the transaction to the log, retrieves the log file as needed, and the CRM compensator (for submitting the transaction and generated log files to the user performing the transaction after the transaction completes).
11, Concurrency: That is, to allow multiple processes in one application to run simultaneously, the process is divided into groups of contexts (the collection of objects with the same requirements) is included in the unit (a set of contexts within a process), a process can contain multiple contexts, All involve objects of different requirements and each context has a unique COM object to provide services such as COM + transaction processing and JIT activation. You can use COM +-provided tools to create multi-tier applications that perform transactions, as well as to handle thread allocation issues. OK, after introducing COM + 's features, you can then describe the COM + type.
COM + has several different types of uses:
1. Application Agent: A file that contains application registration information, that is, when a client accesses a server program on a remote computer, the application agent running on the client writes the information about the server application to the client computer.
2. Server application: The COM + application executes within the process of the COM + application itself, while using concurrency to process components.
3. Library applications: Implemented within the process of a client application, loaded within the client application process, using task-based security, with the disadvantage of not supporting remote access and queue components.
4. COM + Pre-installation application: viewing in the COM + Applications folder in the Component Services in Administrative tools you know what a COM + preinstallation application is, it is an application that is automatically installed into Component Services during COM + installation and cannot be modified or deleted.
It also involves a concept called "Assembly (Assembly)": It is a collection of all types and other resources of the CLR, such as bitmap files. The configuration is available through the administrative tools. NET Framework "to view. Includes assemblies that have private and shared. Private assembly: It is accessible only to applications that have the same path as the assembly. The default is private and must be placed in the folder of the application that uses it. Shared assembly: An assembly that is added to the GAC (Global Assembly Cache). The GAC is designed to hold assemblies so that applications can share them, one thing to be aware of is that assemblies stored in the GAC must have a unique name that can be passed in. NET command Execution window to generate a unique name, called a strong name, after a strong name is generated, a public key is appended to the Assembly to prevent the risk of being replaced by a similar name in the Sn-k assemblyname.snk.
. NET provides two mechanisms for the security of an assembly: one is the strong name mentioned earlier, and the other is the use of signcode, which is understandable as a digital signature. Signcode.exe is used to mark an assembly and embed a digital signature into an assembly, allowing the user to identify the developer who created the assembly.
(Note: In the GAC, you cannot have two strong names of the same name, otherwise it is not a strong name, but you can store multiple copies of one assembly and the assembly in the GAC can only be deleted by a user with certain permissions)
About the version number of the assembly: Each version has a 128-bit version number, which is represented as four: Major (the main version number, changes when the project is changed). Minor (change when adding a feature to the project). Build.revision (the latter two are automatically updated), which can be viewed by AssemblyInfo.cs files in the application.
It's a bunch of theories, and the following is the application of COM +: in. NET, the component that uses COM + services is called. NET service component differs from a generic component in that the former uses COM + services. Use. NET service components are designed to enable access to some of the base classes of COM + services such as ServicedComponent and automatic transaction processing, JIT, object pooling, and security.
In use. NET service components must be registered before service components, there are three ways:
1, Manual registration: Through the RegSvcs.exe command line tool to register, such as: RegSvcs Yourcomponent.dll A yourcomponent.tlb type library is then generated, containing the object's type information (note that you must register a yourcomponent strong name before using this command)
2, Programming Registration: The use of registrationhelper classes, mainly the use of the Iregistrationhelper interface in the method.
3, Dynamic registration: Refers to the implementation of the application process, check the version of the installation components, such as the correct version of the component is not installed, automatically install the required version at run time, that is, autoenrollment. (Note: The user calling autoenrollment must be a member of the Window2000 Administrative group, because dynamic registration cannot change the COM + catalog, otherwise the registration process fails)
Iv. Analysis of examples
1. First, create a new class library. (called Xmloperate in my Project)
It will generate two files, AssemblyInfo.cs and Class1.cs (I changed the Class1.cs to Main.cs, the specific name can be determined)
2. Add Reference (System.EnterpriseServices)
3, back to Main.cs:
Using System;
Using System.Reflection;
Using System.Runtime.InteropServices;
Using System.EnterpriseServices;
Namespace Xmloperator
{
<summary>
Summary description of the ompmsaxmloperator.
</summary>
///
Take away many of my methods, and write a simple visit to demonstrate it OK.
///
[AutoComplete]
public string Visit (string name)
{
Return "Welcome" + name;
}
}
}
4, back to AssemblyInfo.cs, add reference using System.EnterpriseServices;
Add code:
Set the component to server startup mode.
[Assembly:applicationactivation (Activationoption.server)]
Develop Application server name
[Assembly:applicationname ("Xmloperate")]
5, Next, give the server program a strong name (equivalent to registration). Open Visual Studio. Net2003 (maybe you're using the 2005) command prompt, find the address of the file, enter the Sn-k, generate the key such as my file in D disk, work,
D:\work\xmloperate> sn-k xmloperate.snk
Xmloperate.snk is the name of the generated file (after execution, a file will be server.snk)
6, strong name generated, back to the program, in the last few rows in the AssemblyInfo.cs, you can find [Assembly:assemblykeyfile ("")], the file path to write [Assembly:assemblykeyfile (". /.. /xmloperate.snk ")]
7, build the solution, in obj \ Debug will have a XMLOperate.dll, back to Visual Studio. Net2003 command prompt, to file obj\debug directory, execute regsvcs command, register service. (You can do without manual registration, in step 9, when the client calls new when the component service is not registered, the system will automatically register, please see part (c) of the final registration method. )
This is the case in my project.
D:\work\XMLOperate\obj\debug > RegSvcs XMLOperate.dll;
This completes the build of the server.
Open My Computer, Control Panel, management tools, Component Services, COM + applications, and now we can see a lot of COM +, xmloperate This is just the server built.
8, on the Xmloperate Right-click, open the properties, modify security: Call Authentication Level is: None, impersonation level is identity. Authorization to remove the check (these are based on the circumstances need to change, now just do a local on the case). Then find the activation, and change the name of the remote server to the IP address of your own machine.
9, establish the client.
Build a winfrom (there are actually 1 Web service and one window service in my project that call Xmloperate)
Add Reference:
Using System.EnterpriseServices;
Using Xmloperate;
Where the client is going to quote, the new one can be used directly in the method.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.