Appreciate the example. The part that's causing the problem now is that this is running on a windows box and I'm getting an error from POE::Wheel::Run about fork+exec.
MSWin32 does not fully support fork+exec BEGIN failed--compilation aborted at C:/Perl/site/lib/POE/Wheel/Run.pm line 63. Jim Stuck behind a Window... "Lance Braswell" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > > > > Yes. What he said is what I do too. > > I took a couple of minutes and fleshed it out a bit more for you. In > reality I keep stats on my queues and handle shutdowns gracefully. I took > most of that out here and also cleaned up your code a bit. It's untested > but does compile :) [snip] > Lance Braswell - + 1 469 357 6112 > > > > Bas Schulte > <[EMAIL PROTECTED] > net.nl> To > "Jim" <[EMAIL PROTECTED]> > 03/31/2005 03:20 cc > PM poe@perl.org > Subject > Re: Syslog child on Windows > > > > > > > > > > > Jim, > > > On donderdag, maa 31, 2005, at 21:06 Europe/Amsterdam, Jim wrote: > >> If you feel like giving me an example that accomplishes what I want to >> do >> below, I'd be glad to use yours too. :-) > > The concept is fairly simple: instead of connecting to your database in > your 'client_input' state, push the input data at the end of a global > list: > > sub client_input { > > # Get the syslog hash > my $msg = $_[ARG0]; > my $databaseHandle; > my $connectFailureFlag = 0; > my $search; > my $sth; > my $dbName = "vpn"; > # Parse the data for DB entry > $msg->{'msg'} =~ /^(.*?) (\d+)\/(\d+)\/(\d+) > (\d+):(\d+):(\d+)\.(\d+)SEV=. (.*?)$/; > > ## Don't connect to db, just push it on the queue > > push @$queue, $msg; > } > > And before the 'spawn' of POE::Component::Server::Syslog, create a new > session: > > my $queue; ## global, holds queue elements > > POE::Session->create( > inline_states => > { _start => sub { > $_[KERNEL]->delay( tick => 5 ); > }, > > tick => 'doTick' > ); > ); > > sub doTick > { > my ($kernel) = @_[KERNEL]; > > ## connect to db > > ## write all elements in the queue to the database > > foreach my $element (@$queue) { > ## $element->{msg} holds your message > } > > ## disconnect from db > > ## All done now, empty queue > > undef $queue; > > $_[KERNEL]->delay(doTick => 5); > } > > The delay will cause your doTick to be called every 5 seconds, so you > only connect once every 5 seconds instead of connecting on each request. > > You might just as well open the db connection when your tick session > starts, and hold a reference to it in the heap of that session. Then > you'd have to be prepared for the connection getting lost, and > reconnect when it is lost. > > Cheers, > > Bas. > > ps. read about delay here: > http://poe.perl.org/?POE_Cookbook/Recurring_Alarms > > >