RE: Event Dispatcher and Failed Posted Notifications

From: Date: Wed, 26 Jan 2005 16:38:53 +0000
Subject: RE: Event Dispatcher and Failed Posted Notifications
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17177@lists.php.net to get a copy of this message
Bertrand, Thanks for the speedy reply. What you described would solve the problem, but it supposes that the event recipient knows about the passed object from the event poster. This solution seems to imply a tighter coupling between modules than I would like. Anyway, something to chew on. Thanks again, Michael -----Original Message----- CONFIDENTIALITY NOTICE This message contains confidential information intended only for the use of the individual or entity named as recipient. Any dissemination, distribution or copying of this communication by anyone other than the intended recipient is strictly prohibited. If you have received this message in error, please immediately notify us and delete your copy. Thank you. AVIS DE CONFIDENTIALITÉ Les informations contenues aux présentes sont de nature privilégiée et confidentielle. Elles ne peuvent être utilisées que par la personne ou l'entité dont le nom paraît comme destinataire. Si le lecteur du présent message n'est pas le destinataire prévu, il est par les présentes prié de noter qu'il est strictement interdit de divulguer, de distribuer ou de copier ce message. Si ce message vous a été transmis par mégarde, veuillez nous en aviser immédiatement et supprimer votre copie. Merci. From: Bertrand Mansion [mailto:bmansion@mamasam.com] Sent: Wednesday, January 26, 2005 8:23 AM To: Michael Caplan Cc: 'pear-general@lists.php.net' Subject: Re: Event Dispatcher and Failed Posted Notifications Michael Caplan wrote: >Bertrand et al, > > > >I have been paying close attention to the proposed / approved Event >Dispatcher, as it seems to provide a very elegant solution to the problem of >inter-module coupling. I have spent some time in the code and working >through the unit tests to figure out how Event Dispatcher works. I think I >have my head around most of it, but there is one issue I can't seem to >figure out and I am hoping you or anyone else can help me solve it. > > > >The scenario is this: I am coding in an environment which has several >defined modules. Each module provides unique functionality (eg: article >module, calendar module, tracker module, etc....). Under certain scenarios, >these modules will need to interface with each other (eg: an article is >posted into the article module which requires the tracker module to be >updated so that it can track access to the article - or something like >that). So, module A posts an event (which is to be handled immediately) >which the dispatcher then forwards to an observer in module B. All good. >But let's say the event posted to module B fails. For whatever reason, >module A has a strong dependency on module B doing it's work, and upon >failure of module B's handled event it would be most desirable that module A >rolls back. Is there a way that the event poster can become aware of an >event failure (presuming it is an immediately posted event)? I think this might be better handled by exceptions if PHP5 is an option for you. You can also have object A (the poster) be the contained notification object (this is the usual way to go anyway) and have B (the receiver) use the contained object like suck: // In B, this is your callback function receiverMethod(&$notification) { // Do some work... if ($failed) { $A =& $notification->getNotificationObject(); $A->rollback(); $notification->cancelNotification(); } } Good luck, Bertrand Mansion Mamasam

« previous php.pear.general (#17177) next »