Jointcode.shuttle is a service architecture for inter-AppDomain communication.
1. What is the use of jointcode.shuttle ?
In. Net/mono development, it is generally not necessary to use an additional AppDomain, but in some specific cases It may be a good choice to run the code in a new AppDomain.
Jointcode.shuttle is a service framework developed for this purpose when the code needs to access another AppDomain across the AppDomain boundary, creating a cross-appdomain communication problem.
2. Why develop jointcode.shuttle
In general, when making cross-AppDomain calls, most people choose to use the default provided remoting library as the underlying communication mechanism. The code is also simple, for example:
1 namespaceJoitCode.Shuttle.SimpleSample2 {3 Public classMyservice:marshalbyrefobject4 {5 Public voidDo () {}6 }7 8 class Program9 {Ten Static voidMain (string[] args) One { A //Create a child AppDomain in the default AppDomain - varServicedomain = Appdomain.createdomain ("Servicedomain",NULL,NULL); - the varMyService =(myservice) servicedomain.createinstanceandunwrap -(typeof(MyService). Assembly.fullname, - "JoitCode.Shuttle.SimpleSample.MyService"); - + myservice.do (); - + Console.read (); A } at } -}View Code
What's wrong with this approach?
- An AppDomain's access is a single point, that is, it can only be accessed by the host (or parent AppDomain) that created it, not by another AppDomain, even by other AppDomain created by the same host, or even by the parent host of its host.
- Lack of flexibility, which limits flexibility because it requires the service class to inherit the MarshalByRefObject class.
- The architectural design of the remoting library is complex (this is determined by demand because remoting is more than just a cross-AppDomain communication component) and is inherently more suitable for interprocess communication. In fact, interprocess communication is its original intention, and the communication between the AppDomain is only the value that comes from it.
- Remoting performance problems, due to the complexity of the architecture design, inevitably bring additional performance overhead, so the biggest problem it is obviously is that access between the two AppDomain is too slow (test results indicate that cross-appdomain access is hundreds of to 1000 times times slower than normal object access) (example)
- Bidirectional communication. Remoting Although it also supports bidirectional communication, the server needs to use the event/callback if it wants to invoke the client's code. For the communication between the AppDomain, this is not a natural way. In fact, it is also a client-side approach to the service.
3. Features of the Jointcode.shuttle
Compared with remoting, Jointcode.shuttle has its own features in addition to the same functions of cross-AppDomain communication:
- interface/Service Oriented
- Service manageable: Dynamic registration/logoff of service groups
- Better performance: 60~70 times faster than remoting
- Labeling services using Attribute, no intrusion to code
- Strong type, easy to use (remoting relies on magic string to find service classes)
- Built-in IoC capabilities to automatically manage dependencies for services
- Support for deferred load types/assemblies
- Support for accessing services from any AppDomain
- Easy and quick to get started
- More natural communication between any AppDomain (remoting can also achieve two-way communication, but not so natural)
- Remote service lifetime can be managed by lease, or managed by itself
- Support for. NET 2.0
4. Current Limitations
Jointcode.shuttle is a very new framework that is not yet fully functional, and although the authors plan to continue to refine existing functionality and introduce new features in the future, there are still some shortcomings, including:
- Supports only 32-bit applications
- Support for Windows only (only. NET Framework is currently supported, mono is not supported)
- Event not supported temporarily
- Not enough testing.
5. How to use jointcode.shuttle
If you are interested in Jointcode.shuttle, please visit here , we provide a simple example to illustrate how to use this framework.
Jointcode.shuttle, a simple and efficient service framework for cross-AppDomain communication