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