Extract the logic out of commands and controllers.
=> Refactored into Importer classes that can handle a single item at a time.
Event | Message |
---|---|
Blocking | Asynchronous |
Can alter behaviour | No influence |
Deterministic order | Undefined order (of consumers) |
Not scalable | Scalable |
https://symfony.com/doc/current/components/messenger.html#concepts
1 | class UpdatePromotion |
2 | { |
3 | public function __construct( |
4 | public string $id |
5 | ) {} |
6 | } |
1 | private MessageBusInterface $bus ; |
2 | ... |
3 | $this ->bus->dispatch( new UpdatePromotion( $id )); |
1 | $stamps [] = new DelayStamp(20); |
2 | $this ->bus->dispatch( |
3 | new UpdatePromotion( $id ), |
4 | $stamps |
5 | ); |
framework: messenger: transports: neuromancer: dsn: '%env(MESSENGER_TRANSPORT_DSN)%&queue_name=neuromancer' routing: App\Message\NeuromancerMessage: neuromancer
Une Bataille, ~1750, François-Joseph Casanova