Remoting and BLL

Posts   
 
    
Skeeterbug
User
Posts: 165
Joined: 21-May-2004
# Posted on: 09-Aug-2004 14:10:18   

I have decided to go with remoting. I have read all the posts others had on remoting, and I have decided to go with a TCP channel (Which seems to have been proven to be the fastest). I have also downloaded the sample application using remoting and LLBLGen. Right now my business logic layer has a manager class for each entity. It seems I am going to have to create a new remoting object for each manager object I have. Is creating multiple connections to the TCP channel and multiple remoting objects going to cause a performance decrease? I was just wondering if anyone else has done this, and if they have ran into any problems. Thanks!

Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 10-Aug-2004 02:47:40   

You can host all of your objects on the same channel. Dont open a channel per remote object.

Here is a neat little trick that I like to do: when my service host loads up, and runs through its list of remote objects that it must host, I register the remote object using a register method on a web service. I pass in the remote object name, and other key information like the remote hosts connection info.

Then on the client side, when my client starts up, and it needs to get a proxy to the remote object, I send a request to the same web service, and pass in the type of remote object that I am looking for, which returns the connection specific information to the remote host. The client then uses the information from the service to create the proxy.

The web service communicates with a set of SQL Server tables that knows what has been registered. When the remote host is being turned off, all I do is simply call the unregister method on the web service, and now all of the remote objects are no longer available via the web service.

This is also one way that you could "roll your own load balancing"

Hope this helps.

Skeeterbug
User
Posts: 165
Joined: 21-May-2004
# Posted on: 10-Aug-2004 12:58:58   

Devildog74 wrote:

You can host all of your objects on the same channel. Dont open a channel per remote object.

I set up the server like this


                //Create TcpChannel
                TcpChannel channel = new TcpChannel(8090);
                //Register TcpChannel
                ChannelServices.RegisterChannel(channel);

                //=====================================================================================
                //Register Remote Objects
                //=====================================================================================

                //RemoteAccountNumberManager
                RemotingConfiguration.RegisterWellKnownServiceType(
                    typeof(PurchaseOrders_BLL.AccountNumberManager),
                    "RemoteAccountNumberManager",WellKnownObjectMode.SingleCall);

                //RemoteAuthenticateManager
                RemotingConfiguration.RegisterWellKnownServiceType(
                    typeof(PurchaseOrders_BLL.AuthenticateManager),
                    "RemoteAuthenticateManager",WellKnownObjectMode.SingleCall);

This registers all the objects on the same channel (TCP >> Port 8090). This seems to be working ok, and throws no exceptions.

However the client is being a bit more difficult. Maybe I am doing this wrong?


            //Create TcpChannel
            TcpChannel channel = new TcpChannel(remotingPort);
            //Register TcpChannel
            ChannelServices.RegisterChannel(channel);

            //supplier collection
            SupplierManager supmanager = (SupplierManager)Activator.GetObject(
                typeof(PurchaseOrders_BLL.SupplierManager),
                remotingServer + "RemoteSupplierManager");
            EntityCollection suppliers = new EntityCollection(new SupplierEntityFactory());
            suppliers = supmanager.GetAllSuppliers();

            //shipper collection
            ShipperManager smanager = (ShipperManager)Activator.GetObject(
                typeof(PurchaseOrders_BLL.ShipperManager),
                remotingServer + "RemoteShipperManager");
            EntityCollection shippers = new EntityCollection(new ShipperEntityFactory());
            shippers = smanager.GetAllShippers();

The error seems to be after the second Activator.GetObject() is called. It is saying multiple proxies are trying to be created on the same channel.

Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 10-Aug-2004 13:52:07   

Can you show the particular exception?

Skeeterbug
User
Posts: 165
Joined: 21-May-2004
# Posted on: 10-Aug-2004 15:03:48   

I fixed the problem. Magic UI was loading up all the forms and each one had an instance of TcpChannel. So i created the channel in the main form and passed it to all the dockable windows. Works good now. :-D

Thanks for your help!

Skeeterbug
User
Posts: 165
Joined: 21-May-2004
# Posted on: 10-Aug-2004 17:46:36   

BTW, did you mark your classes as Serializable for it to work correctly?

Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 11-Aug-2004 00:05:04   

Yes, I think that all MarshalByRefObjects must be serializable, incliding abstract types. This is because they are serialized and deserialized over the wire.

Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 11-Aug-2004 00:07:04   

Skeeterbug wrote:

I fixed the problem. Magic UI was loading up all the forms and each one had an instance of TcpChannel. So i created the channel in the main form and passed it to all the dockable windows. Works good now. :-D

Thanks for your help!

Instead of passing it, you could create a singleton object on the client side, and just fetch it using the MyHelpers.Instance().MyChannel construct. It might make you coding life simpler.