49 lines
2.2 KiB
YAML
49 lines
2.2 KiB
YAML
name: RoutableMessageBus
|
|
class_comment: '# * Bus of buses that is routable using a BusNameStamp.
|
|
|
|
# *
|
|
|
|
# * This is useful when passed to Worker: messages received
|
|
|
|
# * from the transport can be sent to the correct bus.
|
|
|
|
# *
|
|
|
|
# * @author Ryan Weaver <ryan@symfonycasts.com>'
|
|
dependencies:
|
|
- name: ContainerInterface
|
|
type: class
|
|
source: Psr\Container\ContainerInterface
|
|
- name: InvalidArgumentException
|
|
type: class
|
|
source: Symfony\Component\Messenger\Exception\InvalidArgumentException
|
|
- name: BusNameStamp
|
|
type: class
|
|
source: Symfony\Component\Messenger\Stamp\BusNameStamp
|
|
properties: []
|
|
methods:
|
|
- name: getMessageBus
|
|
visibility: public
|
|
parameters:
|
|
- name: busName
|
|
comment: "# * Bus of buses that is routable using a BusNameStamp.\n# *\n# * This\
|
|
\ is useful when passed to Worker: messages received\n# * from the transport can\
|
|
\ be sent to the correct bus.\n# *\n# * @author Ryan Weaver <ryan@symfonycasts.com>\n\
|
|
# */\n# class RoutableMessageBus implements MessageBusInterface\n# {\n# public\
|
|
\ function __construct(\n# private ContainerInterface $busLocator,\n# private\
|
|
\ ?MessageBusInterface $fallbackBus = null,\n# ) {\n# }\n# \n# public function\
|
|
\ dispatch(object $envelope, array $stamps = []): Envelope\n# {\n# if (!$envelope\
|
|
\ instanceof Envelope) {\n# throw new InvalidArgumentException('Messages passed\
|
|
\ to RoutableMessageBus::dispatch() must be inside an Envelope.');\n# }\n# \n\
|
|
# /** @var BusNameStamp|null $busNameStamp */\n# $busNameStamp = $envelope->last(BusNameStamp::class);\n\
|
|
# \n# if (null === $busNameStamp) {\n# if (null === $this->fallbackBus) {\n# throw\
|
|
\ new InvalidArgumentException('Envelope is missing a BusNameStamp and no fallback\
|
|
\ message bus is configured on RoutableMessageBus.');\n# }\n# \n# return $this->fallbackBus->dispatch($envelope,\
|
|
\ $stamps);\n# }\n# \n# return $this->getMessageBus($busNameStamp->getBusName())->dispatch($envelope,\
|
|
\ $stamps);\n# }\n# \n# /**\n# * @internal"
|
|
traits:
|
|
- Psr\Container\ContainerInterface
|
|
- Symfony\Component\Messenger\Exception\InvalidArgumentException
|
|
- Symfony\Component\Messenger\Stamp\BusNameStamp
|
|
interfaces:
|
|
- MessageBusInterface
|