Skip to content

Instantly share code, notes, and snippets.

@dgafka
Last active May 13, 2022 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgafka/acf81be3b764568ee15675cce3e78aff to your computer and use it in GitHub Desktop.
Save dgafka/acf81be3b764568ee15675cce3e78aff to your computer and use it in GitHub Desktop.
asynchronous-messaging-02.php
<?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