Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: POE, POE::Queue and long running tasks.

by Devanchya (Beadle)
on Aug 30, 2008 at 14:49 UTC ( [id://707923]=note: print w/replies, xml ) Need Help??


in reply to Re: POE, POE::Queue and long running tasks.
in thread POE, POE::Queue and long running tasks.

Your correct. Let me try to summarize it.

- The XML message is a short message coming in from a publication system. There can be hundreds of message a minute. The XML message is the main event for the application
- The XML message needs to be handled in a FIFO system if possible. I put the message into the POE::Queue::Array and check incoming messages to see if they are already in the array to prevent duplicates.
- A wheel will be created that runs a command line vendor that is very CPU intensive. We can only run X amount per server.

The code sample is my very basic poe setup. As you can see how to handle what is going into the Queue is not here... this is where I am getting lost. Thanks for any help...

POE::Session-create( inline_states => { _start => \&task_start, subscribe => \&subscribe, inmessage => \&inmessage, # some other events ... }, ); my $pq = POE::QUEUE::Array->new(); $poe_kernel->run(); exit; sub task_start { my ($kernel, $heap) = @_[KERNEL, HEAP]; $kernel->yield('xmlmsg_open'); } sub xmlmsg_open { my ($kernel, $session) = @_[KERNEL, SESSION]; # Code for a Vendor based XML message connect # Includes a call to a seperate function that opens the subscription +_check } sub subscribe { my ($kernel, $heap, $session, $prearg, $postargs) = @_[KERNEL, HEAP. +..etc]; $kernel->post( $alias => 'subscribe', InXMLMessageCallBack => $session->postback('inmessage' $alias) +, # Other postbacks ); } sub inmessage { my ($kernel, $session, $heap, $preargs, $postargs) = @_[KERNEL, SESSI +ON, HEAP...]; $msg = $postargs->[0]; # code that reads something called getBody from the XML and determin +es the priority of the message. $pq->enqueue( $priority, $msg->getBody); return 1; }
Even smart people are dumb in most things...

Replies are listed 'Best First'.
Re^3: POE, POE::Queue and long running tasks.
by Devanchya (Beadle) on Aug 30, 2008 at 22:34 UTC
    Thanks for the Chatterbox... I am now looking at using POE::Component::JobQueue ... If I get this working I hope to make it a usable example for others who want to learn.
    Even smart people are dumb in most things...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://707923]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-24 05:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found