frzb / transactional-messenger
The TransactionalMessenger component allows make messenger transactional
v1.5.0
2024-08-12 23:19 UTC
Requires
- php: >=8.2
- fp4php/functional: ^6.0
- symfony/event-dispatcher: ^6|^7
- symfony/framework-bundle: ^6|^7
- symfony/http-kernel: ^6|^7
- symfony/messenger: ^6|^7
- symfony/yaml: ^6|^7
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.61
- phpunit/php-code-coverage: ^11.0
- phpunit/phpunit: ^11.2
- symfony/phpunit-bridge: ^6|^7
- symfony/test-pack: ^1.0.10
README
The Transactional Messenger
component allows make messenger transactional
Installation
The recommended way to install is through Composer:
composer require frzb/transactional-messenger
It requires PHP version 8.2 and higher.
Usage #[Transactional]
#[Transactional]
will automatically create and close transaction for your messages,
By default CommitType
is CommitType::OnTerminate
CommitTypes
CommitType::OnTerminate
for requests, executes when response is sent without exceptionsCommitType::OnResponse
for requests, executes when request end without exceptionsCommitType::onHandled
for consumers, executes when message successfully handled
Events
FRZB\Component\TransactionalMessenger\Event\DispatchSucceedEvent
executes when message is dispatchedFRZB\Component\TransactionalMessenger\Event\DispatchFailedEvent
executes when message is failure
Example
<?php use \FRZB\Component\TransactionalMessenger\Attribute\Transactional; #[Transactional] final class CreateUserMessage { public function __construct( public readonly string $id, public readonly string $name, ) { } }