POE::Component::Server::Stomp - A generic Stomp server for POE
use POE qw(Component::Server::Stomp); use Net::Stomp::Frame; use strict; POE::Component::Server::Stomp->new( HandleFrame => \&handle_frame, ClientDisconnected => \&client_disconnected, ClientErrorr => \&client_error ); POE::Kernel->run(); exit; sub handle_frame { my ($kernel, $heap, $frame) = @_[ KERNEL, HEAP, ARG0 ]; print "Recieved frame:\n"; print $frame->as_string() . "\n"; # allow Stomp clients to connect by playing along. if ( $frame->command eq 'CONNECT' ) { my $response = Net::Stomp::Frame->new({ command => 'CONNECTED' }); $heap->{client}->put( $response->as_string . "\n" ); } } sub client_disconnected { my ($kernel, $heap) = @_[ KERNEL, HEAP ]; print "Client disconnected\n"; } sub client_error { my ($kernel, $name, $number, $message) = @_[ KERNEL, ARG0, ARG1, ARG2 ]; print "ERROR: $name $number $message\n"; }
A thin layer over POE::Component::Server::TCP that parses out Net::Stomp::Frames. The synopsis basically covers everything you are capable to do.
For information on the STOMP protocol:
http://stomp.codehaus.org/Protocol
For a full-fledged message queue that uses this module:
POE::Component::MessageQueue
POE::Component::Server::TCP, POE::Filter::Stomp, Net::Stomp
Probably.
Copyright 2007-2010 David Snopek.
To install POE::Component::MessageQueue, copy and paste the appropriate command in to your terminal.
cpanm
cpanm POE::Component::MessageQueue
CPAN shell
perl -MCPAN -e shell install POE::Component::MessageQueue
For more information on module installation, please visit the detailed CPAN module installation guide.