Remoting

Posts   
 
    
RobM
User
Posts: 5
Joined: 05-Sep-2004
# Posted on: 15-Sep-2004 14:49:41   

I'm trying to fit the generated Adapter code to our enviroment and could use help to figure this out.

Let me describe my enviroment.... We have 3 servers; 1 presentation and 2 Business Layers servers using NLB (network load balancing). the presentation server is all web based front end applications that remote to the Business layer. The business layer runs all objects through IIS remoting . I'm using an assembly on the presentation layer called common that has the interfaces for the remoting object. It also contain a classfactory that does the Activator.GetObjects for the IIS remoting objects.

How can I get the Generated code to fit this enviroment? I'm guessing, but I think I the database specific code would go on the business layer and the generic code would go into my common assembly?

Any help is appreciated.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39752
Joined: 17-Aug-2003
# Posted on: 15-Sep-2004 16:07:07   

You place both generated vs.net projects in the BL tier, as it has to work with the entities, and you place the database generic vs.net project in the presentation tier as well.

You can now work in the presentation tier with the entities and you receive them from the BL code / send them to the BL code for persistence actions.

Frans Bouma | Lead developer LLBLGen Pro
RobM
User
Posts: 5
Joined: 05-Sep-2004
# Posted on: 16-Sep-2004 13:43:00   

Forgot to mention that the presentation layer can't see any of our database servers. Will that affect it?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39752
Joined: 17-Aug-2003
# Posted on: 16-Sep-2004 13:59:47   

RobM wrote:

Forgot to mention that the presentation layer can't see any of our database servers. Will that affect it?

No, as the presentation layer just works with the entities, and calls into the remoted BL tier for its data and functionality. the BL handles database access, the presentation layer simply works with the entities it receives from the BL and works with the BL functionality to for example get an entity saved.

Frans Bouma | Lead developer LLBLGen Pro
RobM
User
Posts: 5
Joined: 05-Sep-2004
# Posted on: 16-Sep-2004 14:50:09   

Would I just use Activator.GetObject on the database specific objects from the presentation tier?

Sorry for being so slow on this.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39752
Joined: 17-Aug-2003
# Posted on: 16-Sep-2004 15:05:53   

RobM wrote:

Would I just use Activator.GetObject on the database specific objects from the presentation tier?

Sorry for being so slow on this.

No you don't need that. In the presentation layer you have a reference to the database generic project, which contains the entities.

So you can just do:

CustomerEntity customer = _businessTier.GetCustomer(customerID);

and _businessTier is the object which represents the BL service. The GetCustomer method would simply return a new customer entity, filled with the data belonging to the customer with the ID passed in.

Because the entities are fully serializable through binary / soap remoting, this is fully transparent. In the presentation layer, you now work with the 'customer' object, which doesn't have any persistence logic methods in it, so if you for example want to save it again, you have to call for example: _businessTier.SaveCustomer(customer);

and you pass in the CustomerEntity object.

In the GetCustomer method, which is in the business logic tier, you have a reference to the database specific project, which contains the DataAccessAdapter class. This class makes it possible to read/write with the database.

Frans Bouma | Lead developer LLBLGen Pro
RobM
User
Posts: 5
Joined: 05-Sep-2004
# Posted on: 16-Sep-2004 16:52:44   

I'm not understanding how the _businessTier would be created and why it would have a method GetCustomer. Have you got an example of this?

wayne avatar
wayne
User
Posts: 611
Joined: 07-Apr-2004
# Posted on: 16-Sep-2004 17:10:44   

RobM wrote:

I'm not understanding how the _businessTier would be created and why it would have a method GetCustomer. Have you got an example of this?

Hi RobM

I know there is an example of this somewhere...

Have a look at the following threads maybe it can give you some idea:

  1. Passing Entities accross tiers - http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=802
  2. Collections in the business layer - http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=811
  3. Passing Collections or DataTables - http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=834

**One of the experts on remoting here on this forum is a guy calling himself DevilDog - have a look at his posts. Do a search on Remoting there's lots.simple_smile ** Another person you can try that uses Adapter with a BL is MattWoberts.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39752
Joined: 17-Aug-2003
# Posted on: 16-Sep-2004 17:12:03   

RobM wrote:

I'm not understanding how the _businessTier would be created and why it would have a method GetCustomer. Have you got an example of this?

Yes, there is a small example of this in the Examples section in the customer area. It is a simple client and server example where the server sets up a remoted channel and the client requests a customer object from the server and the server fetches that object and returns it.

The Server in this is your business logic tier, the client is the presentation layer in your application. The example uses selfservicing to fetch the entity, but the main point is the communication. (the server can be updated to use both generated projects, to fetch the entity, the client can just reference the database generic project. )

Frans Bouma | Lead developer LLBLGen Pro
RobM
User
Posts: 5
Joined: 05-Sep-2004
# Posted on: 16-Sep-2004 18:17:47   

Thanks for the replys!

In the example is uses a Singleton. Will it work using a Single Call? The object are not stateful correct?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39752
Joined: 17-Aug-2003
# Posted on: 16-Sep-2004 19:14:16   

RobM wrote:

Thanks for the replys!

In the example is uses a Singleton. Will it work using a Single Call? The object are not stateful correct?

The service, the server process, is likely a singleton process, but that depends on how you setup remoting. (i.e.: you can decide to create the remoted process per call, or you can decide to keep it alive to let it serve other requests as well. Please consult .NET remoting documentation for details on this).

I don't think it is wise to 'assume' a given state on the server, i.e. I think if a client wants the server to do something, like saving some data, the data has to be provided by the client, the client shouldn't be assuming that the server is still holding some sort of reference in memory. (thus the server process should be stateless)

All entities and entity collections are passed by value. This means that when you access a property, no call is made to the server. (you can also pass a remoted object by reference, which means that you get a proxy object on the client which marshalls (transfers/converts) each call to the server, and which is thus very resource intensive and can lead to very 'chatty' applications: the clients bombard the server with remote calls, which can lead to severe problems, hence the pass by value simple_smile

Frans Bouma | Lead developer LLBLGen Pro
wayne avatar
wayne
User
Posts: 611
Joined: 07-Apr-2004
# Posted on: 21-Sep-2004 15:15:36   

Now i have a question about remoting.simple_smile

The example on the website show a client and server side example - great. sunglasses Few relating questions...

I had a look at the server side project confused Why is the server side a console application? Is that the right project type to use? Is there not maybe something else that would work better? Could a service not be used?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39752
Joined: 17-Aug-2003
# Posted on: 21-Sep-2004 15:48:51   

The console app was made for testing it out. You can embed the functionality in any program type.

Frans Bouma | Lead developer LLBLGen Pro
wayne avatar
wayne
User
Posts: 611
Joined: 07-Apr-2004
# Posted on: 21-Sep-2004 15:57:20   

Otis wrote:

The console app was made for testing it out. You can embed the functionality in any program type.

If you had to do it - what would you use?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39752
Joined: 17-Aug-2003
# Posted on: 21-Sep-2004 17:10:47   

wayne wrote:

Otis wrote:

The console app was made for testing it out. You can embed the functionality in any program type.

If you had to do it - what would you use?

A windows service probably, although a service hosted by IIS has additional functionality: security which is build in IIS.

Frans Bouma | Lead developer LLBLGen Pro