22
33namespace OldSound \RabbitMqBundle \RabbitMq ;
44
5+ use OldSound \RabbitMqBundle \Event \AfterProcessingMessageEvent ;
6+ use OldSound \RabbitMqBundle \Event \BeforeProcessingMessageEvent ;
7+ use OldSound \RabbitMqBundle \Event \OnConsumeEvent ;
58use OldSound \RabbitMqBundle \RabbitMq \BaseConsumer ;
69use PhpAmqpLib \Message \AMQPMessage ;
710
@@ -44,6 +47,7 @@ public function consume($msgAmount)
4447 $ this ->setupConsumer ();
4548
4649 while (count ($ this ->getChannel ()->callbacks )) {
50+ $ this ->dispatchEvent (OnConsumeEvent::NAME , new OnConsumeEvent ());
4751 $ this ->maybeStopConsumer ();
4852 $ this ->getChannel ()->wait (null , false , $ this ->getIdleTimeout ());
4953 }
@@ -67,9 +71,16 @@ public function delete()
6771
6872 public function processMessage (AMQPMessage $ msg )
6973 {
74+ $ this ->dispatchEvent (BeforeProcessingMessageEvent::NAME ,
75+ new BeforeProcessingMessageEvent ($ msg )
76+ );
7077 try {
7178 $ processFlag = call_user_func ($ this ->callback , $ msg );
7279 $ this ->handleProcessMessage ($ msg , $ processFlag );
80+ $ this ->dispatchEvent (
81+ AfterProcessingMessageEvent::NAME ,
82+ new AfterProcessingMessageEvent ($ msg )
83+ );
7384 $ this ->logger ->debug ('Queue message processed ' , array (
7485 'amqp ' => array (
7586 'queue ' => $ this ->queueOptions ['name ' ],
0 commit comments