Have you taken a look at the POE Cookbook?
POE seems to be one of the best documented of all the perl modules/subsytems.
That I find most thngs you would use POE for easier with threads, in no way detracts from the excellence of POE.
Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
| [reply] |
I have, almost 2 years back, and ended up using solutions in Network Programming with Perl insead. It's great to see that the POE recipe list seems to have grown quite a lot in the interim. Thanks for bringing it up.
| [reply] |
The chat server recipe in POE's cookbook contains a very simple example of publish/subscribe within a single process. I recommend POE::Component::IKC if you want to publish and subscribe to services between separate processes.
As I see it, the difference between events and messages is one of scale. Events are essentially messages telling a program that some fairly small thing has occurred. At POE's lowest levels, it generates events to indicate when sockets are ready to be read from or written to. It implements multiple timers with notification as events. It does a bunch of other things, but they're outside the scope of this reply. :)
Messages on the other hand are high-level notifications. For example, POE::Component::Server::SOAP notifies programs when entire SOAP requests have arrived. It accepts SOAP responses and handles the gory details of shipping them back to clients.
-- Rocco Caputo - http://poe.perl.org/
| [reply] |
This exact subject came up for me lately too. And I would also love to learn more about it. Any discussion, code samples, or suggested reading on the topic as it relates to Perl would be greatly appreciated and thoroughly ++d.
| [reply] |
One particular question I have is whether POE fits/supports the publish/subscribe type of messaging? e.g., if more than one component wants to handle a POE event, how to do that?
As far as I know, there is no built-in mechanism for doing that in POE. It is trivially easy to implement yourself, though. Take a look at POE::Component::IRC's register code to see an example. Also, you might want to take a look at its _send_event subroutine to see how the events are actually sent to each registered session. Pretty straightforward stuff.
Update: in reply to:
Furthermore, if an event needs to be processed in several steps (sort of like Apache's request handling cycle), what's the best approach to do that in POE?
The easiest way is simply to post to the next event in the sequence. So event1 gets triggered, which does some stuff, then posts to event2. If you want some sort of centally managed way to do that, again, you'll have to do it yourself. But it wouldn't be too difficult.
| [reply] [d/l] [select] |