Hello from a POE beginner!
I've been getting my feet wet with POE over the last few days. So far, I'm really impressed with all the cleverness!
I'm planning to build an application server using PoCo::IKC and PoCo::JobQueue. Today I added some stuff to have my skeleton do some actual work (instead of just printing "hello" from various event handlers ;)
I had added "use XML::Simple" to my server, and it dies on the first received call with a complaint about Storable not having store or freeze methods.
The server starts fine, but as soon as I fire up the client that calls the server, the server dies:
Storable doesn't have a freeze or nfreeze method at /usr/local/share/perl/5.6.1/POE/Component/IKC/Channel.pm line 357 Storable doesn't have a thaw method at /usr/local/share/perl/5.6.1/POE/Component/IKC/Channel.pm line 357 Can't use string ("") as a subroutine ref while "strict refs" in use at /usr/local/share/perl/5.6.1/POE/Filter/Reference.pm line 175.
That can't be right.
As soon as I "use Storable" before "use"ing XML::Simple, the error goes away and everything works like a charm. It does not work when I use XML::Simple after using POE modules though. I have the feeling (without having looked in the source code) that somewhere deep down, POE is picking up on the fact that Storable has been loaded, but doesn't check whether its methods have been exported. Of course, I may be completely wrong.
Note that I have my workaround, so it's nothing urgent to me, I just wanted to report it to see if someone more knowledgeable can explain this.
Thanks, Rhesa Rozendaal
Here's my IKC server. It's basically the example from the cookbook.
#!/usr/bin/perl use warnings; use strict;
# use Storable; # uncomment this line to make it work use XML::Simple;
use POE qw(Session); use POE::Component::IKC::Server; use POE::Component::IKC::Specifier;
# Create an IKC server. It runs as a separate session, and does # message passing for us. POE::Component::IKC::Server->spawn( port => 31338, name => 'Application', );
# Create a session that will be accessible through an IKC network.
POE::Session->create( inline_states => { _start => \&service_start, foo => \&service_foo, } );
POE::Kernel->run();
# Start the service. Set up an alias, which is our service's name. # Call IKC to publish the service and some public events.
sub service_start { my ( $kernel, $heap ) = @_[ KERNEL, HEAP ];
my $service_name = "application"; $kernel->alias_set($service_name); $kernel->call( IKC => publish => $service_name, ["foo"] ); }
sub service_foo { my ( $kernel, $heap, $request ) = @_[ KERNEL, HEAP, ARG0 ]; my ( $data, $rsvp ) = @$request; $kernel->call( IKC => post => $rsvp, "Foo!" ); }
exit(0);
And here's the accompanying client. Again copied from the cookbook.
#!/usr/bin/perl
use warnings; use strict;
use POE::Component::IKC::ClientLite; # Create an IKC client. This also establishes a connection to an IKC # server. Part of the registration process is choosing a unique name # for ourselves, which we do naively by abusing the process ID.
my $name = "Client$$"; my $remote = create_ikc_client( port => 31338, name => $name, timeout => 10, ); die $POE::Component::IKC::ClientLite::error unless $remote;
my $status = $remote->post_respond( 'application/foo'); die $POE::Component::IKC::ClientLite::error unless defined $status;
exit 0;