johnnywang has asked for the wisdom of the Perl Monks concerning the following question:

In POE, is it possible to register multiple event handlers for a single event? sort of like publish/subscribe messaging. For example, suppose I have an "order" event, I'd like several handlers to be invoked: one to insert into db, one to log, one to send email, etc. I could send multiple events, but that's not as nice.

Replies are listed 'Best First'.
Re: POE: multiple event handlers
by RMGir (Prior) on Apr 12, 2005 at 13:04 UTC
    (Edit: Found POE_Cookbook answer.)

    I deleted my initial idea; I don't think it would have worked.

    Check out http://poe.perl.org/?POE_Cookbook/Broadcasting_Events. The event registry approach looks like it's what you need.

    If you come up with a cool solution, please follow up to your node. I'm looking forward to seeing the correct solution.


    Mike
      Broadcasting solves a slightly different problem, namely sending the same event to all sessions. My problem is to have multiple event-handlers within the same session, so I can call yield() and still got handler multiple times. One hack is to re-send multiple events, but that's ugly.