On Fri, Dec 13, 2002 at 11:27:35AM +0000, Kaare Rasmussen wrote:
> My project needs some kind of work offloading from the user interface side. 
> Most of the time the user will just update data, but there are some tasks 
> that can be very time consuming. This is a financial application, so these 
> tasks include invoicing, document creation, and more. These tasks could 
> benefit from being treated as batch jobs. 
> 
> I'm thinking to implement kind of an application server for this. A server 
> could receive some kind of user/password information and a description of 
> which kind of job to perform together with any necessary data. It would 
> perform the action and then go to sleep. If more requests are send 
> simultaneously, they should all be applied. Best would be if there could be 
> configuration choices for how many processes (if any) could run at the same 
> time.

You mentioned looking at "Application Servers" in the POE Cookbook
page.  As it is written, it processes one task at a time and "sleeps"
between them.

The cookbook also includes a "Job Server" recipe.  It's more of an
inetd-style server than an application server, but it shows how POE
can be used to manage parallel processes.  See:
http://poe.perl.org/?POE_Cookbook/Job_Server

The application you've specified would combine aspects of both
examples.

> It is a web based application, so it lives in an Apache process. It also 
> relies on mod_perl and Embperl. It would be preferably if the server could 
> be run within the same process, as a stand alone service on the same server 
> or on one or more external servers.

POE is appropriate in a separate process, either on the same machine
or on a different one.

It is not practical to run POE within Apache, but you can certainly
embed a web server within a POE program.  Two ways to serve web (and
web-like) content from POE:

POE::Component::Server::HTTP
POE::Component::Server::SOAP

You've already mentioned that you won't be serving general content
from POE.  That's good because special-purpose code like Apache is
almost always better at what it's designed to do.

> Also, as this is a financial application, security is very important. I 
> touched the topic of logging in, but what about encrypting the  client / 
> server trafic?

POE works with any type of socket that looks like a plain socket.
This includes tied sockets, such as Net::SSLeay::Handle.

Unfortunately, Net::SSLeay::Handle only covers the client side of an
SSL connection.  Fortunately, it was trivial to create a server side
version.  I will be using them to add SSL support to POE as soon as I
find the right way to package them.  In the meantime, I can provide
the code if you're interested.

> I do have some other more vague thoughts about timed events. Having this 
> application server run tasks based on a schedule. 

POE provides generic timers.  It's easy to schedule tasks with them.

> Can POE be used for this? I've looked at the "Application Servers" entry in 
> the POE Coolbook, and it seems simple. But is it that simple, and will it 
> work in the above mentioned environment? I don't want POE to control my 
> whole application, as most of the time it will deal with user input and web 
> pages. So the client code could be embedded in a web page. 

It's certainly possible to use POE as a back-end application server.

POE::Filter::Reference may be used in stand-alone Perl programs,
including lightweight CGI interfaces.  The Application Servers example
can also use YAML, which has bindings for several languages other than
Perl.  Finally, you may specify your own protocol for passing requests
and results between (for example) PHP pages and a POE back end
processor.

Philip Gwyn has been doing similar things for years.  He has yet to
release JAAS, but the code is available from http://pied.nu/Perl/JAAS/

-- Rocco Caputo - [EMAIL PROTECTED] - http://poe.perl.org/

Reply via email to