newbie question

  • Thread starter Thread starter Guest
  • Start date Start date
Hi Tia,

There are two types of activation for marshal-by-reference objects:

Server activation.
Server-activated objects are created by the server only when they are needed.
They are not created when the client proxy is created by calling new or Activator.GetObject,
but rather when the client invokes the first method on that proxy. For details, see Server Activation.

You use the the WellKnownObjectMode enumeration to configure server-activated objects as
Singleton or SingleCall objects. Singleton objects are objects for which there will always be
only one instance, regardless of how many clients there are for that object, and which have a
default lifetime. (The client can use the lifetime lease system to participate in the lifetime of
Singleton instances. For details, see Lifetime Leases.) When you configure an object to be a
SingleCall object, the system creates a new object for each client method invocation. Because a
client will get a reference to a new instance on each invocation, SingleCall types do not participate
in the lifetime lease system.

You can refer to the following link for more information on Server Activation:
[Server Activation]
http://msdn.microsoft.com/library/d.../en-us/cpguide/html/cpconserveractivation.asp

Client activation.
Client-activated objects are created on the server when the client calls new or Activator.CreateInstance.
The client itself, using the lifetime lease system, can participate in the lifetime of these instances.

You can refer to the following link for more information on Client Activation:
[Client Activation]
http://msdn.microsoft.com/library/d.../en-us/cpguide/html/cpconclientactivation.asp

HTH

Mona[Grapecity]
 
To me the main difference is that server activated objects are generally useful whereas client activated ones are not

I obviously need to expand on that ;-)

Server activation supports two modes: Singleton and SingleCall. Singleton means that there is only once instance at a time servicing calls (it does not mean a single instance will service every call over the lifetime of your application because of the distributed garbage collection infrastructure - if no one calls it for a while it will be disconnected from the remoting infrastructure when its lease expires). SingleCall means every call gets a new instance.

Client activation means each client gets their own copy (or multiple copies I guess if they make multiple calls to Activator.CreateInstance).

So the issue is "why would I use client activation?". The only real use of this that I have come across is to maintain per-client state in a simple way. Heres why I think this is a bad idea:

1) if the process dies you lose all of you per-client state
2) you cannot load balance the application as all state for a particular client is held in memory in a single process
3) You have to pay attention to the demands of distributed lifetime management

Its better IMO to use Singletons, keep the per-client state in a database and pass a client identifier in each method call. With singletons you have to ensure that you are not keeping state in the object itself (or pay the cost of thread synchronization which makes the code harder to write - but this can be alleviated by use of a ReaderWriterLock).

As far as the client getting involved in the lifetime policy of the object, this invloves having to register a sponsor for the object. The lease manager will now call the sponsor to check if its OK to disconnect the object when the lease expires. This is bascially a re-implementation of the DCOM ping architecture (although now you can configure the timeouts). The problem with this is that in complex systems the ping traffic became significant. Also the ping tended to be blocked by firewalls (as they often let traffic through in one direction but not the other way) because for sponsors to work the server has to call the client (you get the same issues with remoting callbacks).

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

Hi Tia, There are two types of activation for marshal-by-reference objects: Server activation.
Server-activated objects are created by the server only when they are needed. They are not created when the client proxy is created by calling new or Activator.GetObject, but rather when the client invokes the first method on that proxy. For details, see Server Activation. You use the the WellKnownObjectMode enumeration to configure server-activated objects as Singleton or SingleCall objects. Singleton objects are objects for which there will always be only one instance, regardless of how many clients there are for that object, and which have a default lifetime. (The client can use the lifetime lease system to participate in the lifetime of Singleton instances. For details, see Lifetime Leases.) When you configure an object to be a SingleCall object, the system creates a new object for each client method invocation. Because a client will get a reference to a new instance on each invocation, SingleCall types do not participate in the lifetime lease system. You can refer to the following link for more information on Server Activation: [Server Activation] http://msdn.microsoft.com/library/d.../en-us/cpguide/html/cpconserveractivation.asp Client activation.
TIA. This post contained attachments. By default, NewsGator will not download attachments, but can be configured to do so. If you wish to automatically download attachments for this newsgroup, go to NewsGator/Subscriptions, select this group and click Edit, and change the Options.


[microsoft.public.dotnet.framework]
 
Back
Top