Thursday, February 4, 2010

Important points for .Net Remoting

.Net Remoting produce good performance in terms of speed when use with TCP channel and the binary formatter.
.Net remoting when hosted in IIS, can benefit from all the security features of IIS. If you use TCP or HTTP channel hosted in processes other than aspnet_wp.exe, you need to implement security features on your own.
.NET Remoting supports state management with Singleton objects.

Remote Objects activation 

 The behavior of remoting object is determined by the ways object is created and activated. There are two ways of activation for .NET remote objects.

Server Activation

In server activation, the object is created on the server when method call arrives from client to server process. But the object doesn't get created when you use new keyword to create instance of the server class.
You can specify server activated objects to acts either as singleton or Single Call objects.
SingleCall: If an object is declared as SingleCall object, the remoting system creates an object each time a client method invokes a remote object. SingleCall objects are useful when limited work expected from the objects. These objects cannot hold state information between method calls.
Singleton Objects: A single instance of the server class manages the entire client. These objects serve multiple clients with one instance. This mode allows maintaining object's state which can be useful when data needs to be shared explicitly between clients.
Client-Activated Objects: The client-activated object is created on the server when an instance of the server class is created using new keyword. When you create instance of server object, a connection is made to the server and the client proxy is created. These objects can maintain state information between method calls for the client.

Life Time of Remote Object.

A lease is created for every object that can be transported across domain. The lease controls the lifetime of the object. The remoting object serves client until its lease expires. When the lease expires, the object is disconnected from the client and available to get destroyed by garbage collection.

.Net Remoting Channels

Channels are the objects that remote objects use to communicate with each other. It allows applications to send and receive messages using protocols such as TCP and HTTP. It is a message carrier that converts the message in either as XML or binary format before sending message across boundary.
In .Net Framework, channel's classes and interfaces are included in System.Runtime.Remotig.Channels namespace. A channel needs to be registered to the remoting system infrastructure both at client and server side before it receives or send data.
Based on the protocol used by the channel, you have
HTTPChannel
TCPChannel

HTTPChannel

.Net Framework provides System.Runtime.Remoting.Channels.http namespace that provides classes to use HTTPChannel. You can use HTTPChannel when interoperability is the main issue. HTTPChannel uses SOAPformatter to serialize messages into XML format before sending messages.

TCPChannel

.Net Framework provides System.Runtime.Remoting.Channels.tcp namespace that provides classes to use TCPChannel. This kind of channel is used when performance is main issue. TCPChannel uses BinaryFormatter to serialize messages into binary stream before sending messages.

0 Comments: