@@ -423,112 +423,6 @@ your ``transports`` configuration or it can be your own receiver.
423
423
It also requires a ``--bus `` option in case you have multiple buses configured,
424
424
which is the name of the bus to which received messages should be dispatched.
425
425
426
- Multiple Buses
427
- --------------
428
-
429
- If you are interested in architectures like CQRS, you might want to have multiple
430
- buses within your application.
431
-
432
- You can create multiple buses (in this example, a command bus and an event bus) like
433
- this:
434
-
435
- .. configuration-block ::
436
-
437
- .. code-block :: yaml
438
-
439
- # config/packages/messenger.yaml
440
- framework :
441
- messenger :
442
- # The bus that is going to be injected when injecting MessageBusInterface:
443
- default_bus : messenger.bus.commands
444
-
445
- # Create buses
446
- buses :
447
- messenger.bus.commands : ~
448
- messenger.bus.events : ~
449
-
450
- .. code-block :: xml
451
-
452
- <!-- config/packages/messenger.xml -->
453
- <?xml version =" 1.0" encoding =" UTF-8" ?>
454
- <container xmlns =" http://symfony.com/schema/dic/services"
455
- xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
456
- xmlns : framework =" http://symfony.com/schema/dic/symfony"
457
- xsi : schemaLocation =" http://symfony.com/schema/dic/services
458
- http://symfony.com/schema/dic/services/services-1.0.xsd
459
- http://symfony.com/schema/dic/symfony
460
- http://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
461
-
462
- <framework : config >
463
- <framework : messenger default-bus =" messenger.bus.commands" >
464
- <framework : bus name =" messenger.bus.commands" />
465
- <framework : bus name =" messenger.bus.events" />
466
- </framework : messenger >
467
- </framework : config >
468
- </container >
469
-
470
- .. code-block :: php
471
-
472
- // config/packages/messenger.php
473
- $container->loadFromExtension('framework', array(
474
- 'messenger' => array(
475
- 'default_bus' => 'messenger.bus.commands',
476
- 'buses' => array(
477
- 'messenger.bus.commands' => null,
478
- 'messenger.bus.events' => null,
479
- ),
480
- ),
481
- ));
482
-
483
- This will generate the ``messenger.bus.commands `` and ``messenger.bus.events `` services
484
- that you can inject in your services.
485
-
486
- .. note ::
487
-
488
- To register a handler only for a specific bus, add a ``bus `` attribute to
489
- the handler's service tag (``messenger.message_handler ``) and use the bus
490
- name as its value.
491
-
492
- Type-hints and Auto-wiring
493
- ~~~~~~~~~~~~~~~~~~~~~~~~~~
494
-
495
- Auto-wiring is a great feature that allows you to reduce the amount of configuration
496
- required for your service container to be created. When using multiple buses, by default,
497
- the auto-wiring will not work as it won't know which bus to inject in your own services.
498
-
499
- In order to clarify this, you can use the DependencyInjection's binding capabilities
500
- to clarify which bus will be injected based on the argument's name:
501
-
502
- .. configuration-block ::
503
-
504
- .. code-block :: yaml
505
-
506
- # config/services.yaml
507
- services :
508
- _defaults :
509
- # ...
510
-
511
- bind :
512
- $commandBus : ' @messenger.bus.commands'
513
- $eventBus : ' @messenger.bus.events'
514
-
515
- .. code-block :: xml
516
-
517
- <!-- config/services.xml -->
518
- <?xml version =" 1.0" encoding =" UTF-8" ?>
519
- <container xmlns =" http://symfony.com/schema/dic/services"
520
- xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
521
- xsi : schemaLocation =" http://symfony.com/schema/dic/services
522
- http://symfony.com/schema/dic/services/services-1.0.xsd" >
523
-
524
- <services >
525
- <defaults >
526
- <bind key =" $commandBus" type =" service" id =" messenger.bus.commands" />
527
- <bind key =" $commandBus" type =" service" id =" messenger.bus.events" />
528
- </defaults >
529
- </services >
530
- </container >
531
-
532
426
Middleware
533
427
----------
534
428
@@ -928,4 +822,12 @@ will give you access to the following services:
928
822
#. ``messenger.sender.yours ``: the sender;
929
823
#. ``messenger.receiver.yours ``: the receiver.
930
824
825
+ Learn more
826
+ ----------
827
+ .. toctree ::
828
+ :maxdepth: 1
829
+ :glob:
830
+
831
+ /messenger/*
832
+
931
833
.. _`enqueue's transport` : https://github.com/php-enqueue/messenger-adapter
0 commit comments