You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+43Lines changed: 43 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -316,6 +316,49 @@ If you need to use a custom class for a producer (which should inherit from `Old
316
316
317
317
The next piece of the puzzle is to have a consumer that will take the message out of the queue and process it accordingly.
318
318
319
+
#### Producer Events ####
320
+
321
+
There are currently two events emitted by the producer.
322
+
323
+
##### BeforeProducerPublishMessageEvent #####
324
+
This event occurs immediately before publishing the message. This is a good hook to do any final logging, validation, etc. before actually sending the message. A sample implementation of a listener:
325
+
326
+
```php
327
+
namespace App\EventListener;
328
+
329
+
use OldSound\RabbitMqBundle\Event\BeforeProducerPublishMessageEvent;
330
+
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
public function __invoke(BeforeProducerPublishMessageEvent $event): void
336
+
{
337
+
// Your code goes here
338
+
}
339
+
}
340
+
```
341
+
342
+
##### AfterProducerPublishMessageEvent #####
343
+
This event occurs immediately after publishing the message. This is a good hook to do any confirmation logging, commits, etc. after actually sending the message. A sample implementation of a listener:
344
+
345
+
```php
346
+
namespace App\EventListener;
347
+
348
+
use OldSound\RabbitMqBundle\Event\AfterProducerPublishMessageEvent;
349
+
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
public function __invoke(AfterProducerPublishMessageEvent $event): void
355
+
{
356
+
// Your code goes here
357
+
}
358
+
}
359
+
```
360
+
361
+
319
362
### Consumers ###
320
363
321
364
A consumer will connect to the server and start a __loop__ waiting for incoming messages to process. Depending on the specified __callback__ for such consumer will be the behavior it will have. Let's review the consumer configuration from above:
0 commit comments