Last active
May 13, 2022 06:43
-
-
Save dgafka/acf81be3b764568ee15675cce3e78aff to your computer and use it in GitHub Desktop.
asynchronous-messaging-02.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# config/packages/messenger.yaml | |
framework: | |
messenger: | |
buses: | |
messenger.bus.default: | |
middleware: | |
- 'AddExecutorIdMiddleware' | |
class AddExecutorIdMiddleware implements MiddlewareInterface | |
{ | |
public function handle(Envelope $envelope, StackInterface $stack): Envelope | |
{ | |
// You may change the Message here or add addtional behaviour. | |
$envelope = $envelope->with(new ExecutorStamp($id)); | |
// Or stop execution by not calling next. | |
return $stack->next()->handle($envelope, $stack); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment