Via Composer:
$ composer require nepada/message-bus-netteRegister the extension in config.neon:
extensions:
messageBus: Nepada\MessageBusNette\DI\MessageBusExtensionSee nepada/message-bus for the documentation of the core library.
The extension tries to autowire PSR compatible logger into logging middleware. If this doesn't work for you, specify the logger service in configuration explicitly:
messageBus:
logger: @myLoggerServiceNested command handling is not allowed by default, this can be changed in configuration:
messageBus:
allowNestedCommandHandling: trueDoctrine ORM specific features for message bus are provided by nepada/message-bus-doctrine package. Follow the link for more detailed documentation. Once you install the package, it gets detected by DI extension and all necessary services are set up.
With Doctrine integration:
- all commands are handled in a transaction and all changes are automatically flushed and commited after the handler successfully finishes, or rolled back on error,
- database transactions started outside of command bus are forbidden,
- entity manager is (optionally) cleared before and after the handling of every command.
Change or completely disable the default entity manager clearing logic:
messageBus:
clearEntityManager
onStart: false
onSuccess: false
onError: falseYou can record your domain events inside entities implementing Nepada\Bridges\MessageBusDoctrine\Events\ContainsRecordedEvents and they will be automatically collected and dispatched on flush.
search:
messageBusHandlers:
in: %appDir%
implements:
- Nepada\MessageBus\Commands\CommandHandler
- Nepada\MessageBus\Events\EventSubscriber