Sending CommandObjects to different servers

Sending CommandObjects to different servers

Old forum URL: forums.lhotka.net/forums/t/1637.aspx


davidk posted on Tuesday, October 31, 2006

I'm looking for a way to send CommandObjects to different servers.  My command objects perform tasks on things like the file system so they need to run on servers other than the application server.  All my regular objects need to be loaded/saved through the application server using default CSLA functionality but I need to have a way to send command objects to a machine that is not the application server.  I'm trying to find a way to do this without changing anymore of the CSLA code than necessary so I can easily migrate to new versions of the framework as they are released.  It's easy enough at runtime to pass the target server name to the command object it's just a matter of getting that command object routed to the proper destination.  Any ideas?  Have I made my requirement clear?

 

Thanks for any input.

Bayu replied on Tuesday, October 31, 2006

Hi,

I believe the command objects of CSLA are strictly for use with dataportal related functionality.

So I guess you just seek another way of communicating to other machines:

- you could do what CSLA does, use remoting;
    - then you would have to setup a remoting channel
    - when that's done you can submit anything through it that is marked as Serializable
    - performance is great
    - however, remoting is platform specific

- you could also create a web-service
    - your target machine would need to run a webserver and expose a webservice on it
    - it's xml-based (soap), so should be platform independent
    - performance is reasonable

- you could setup Messaging
    - simple and light-weight
    - never done this, but it should not be too hard
    - I believe this one is platform specific again, but I don't know for sure
    - is typically asynchronous, so I don't know if it is of use to you
    - deals automatically with broken network communications

- the hardcore way: setup your own TCPListener
    - and use a TCPClient to submit data to the listener
    - you can send anything you like, but you will have to implement a protocol yourself
    - performance is superior
    - platform indepent (unless you choose a platform specific protocol like serialization)


Hopefully this gives you some leads (or keywords to search for on Google ;-) ). Depending on your use case different approaches could be preferred. What do you need? Synchronous or is asynchronous fine as well? Do you need platform indepence or is that not a constraint? What is your performance requirement?

Regards,
Bayu


davidk replied on Tuesday, October 31, 2006

Thanks bayu.

Prior to adopting CSLA I implemented this functionality with custom TCPListener and TCPClient which worked but since platform independence wasn't an issue I eventually changed it to use remoting.  There is just so much plumbing already done in CSLA that I was hoping to leverage it now that I am using the framework but it sounds like implementing my own remoting code outside of CSLA may be the best way to make this happen.  I just wanted to make sure there wasn't some existing hook in the framework for something like this before I went off on my own. 

The jobs that I am running will run asynchronously.  Here is a simple example - every evening I want to compress files on a file server based on some criteria that the user has defined through the front-end.  The code on the application server handles starting this compression job when it is due but the job needs to run on the file server for performance reasons.  So, at the designated time the app server sends a command object to the file server, the file server runs the compression job, then calls back to the app server with the results.  The app server sticks the results in the database so that the next time the user opens the front-end he can see that the job ran successfully, how long it took, etc.  Sounds like what I'll do is have the app server invoke the job through remoting on the file server then have the file server update the status of the job (a csla business object) so the results are saved to the database.  So, the job is a csla object and the file server can update it using existing csla functionality but I'll have to launch the job outside of csla.

Bayu replied on Tuesday, October 31, 2006

davidk:

I just wanted to make sure there wasn't some existing hook in the framework for something like this before I went off on my own. 

None that I now of .... so I think you will have to do it yourself. However, you are in fact leveraging a framework .... it's just not csla. ;-) Having experience with TCP Listeners (which you have too apparently) this is already quite a timesaver.

davidk:

The jobs that I am running will run asynchronously.  Here is a simple example - every evening I want to compress files on a file server based on some criteria that the user has defined through the front-end.  The code on the application server handles starting this compression job when it is due but the job needs to run on the file server for performance reasons.  So, at the designated time the app server sends a command object to the file server, the file server runs the compression job, then calls back to the app server with the results.  The app server sticks the results in the database so that the next time the user opens the front-end he can see that the job ran successfully, how long it took, etc.  Sounds like what I'll do is have the app server invoke the job through remoting on the file server then have the file server update the status of the job (a csla business object) so the results are saved to the database.  So, the job is a csla object and the file server can update it using existing csla functionality but I'll have to launch the job outside of csla.



You could opt for messaging if you also want to be robust to failing network connections. But it sounds like you have it quite under control already. Nice!

Bayu

Copyright (c) Marimer LLC