frzb/transactional-messenger

The TransactionalMessenger component allows make messenger transactional

v1.5.0 2024-08-12 23:19 UTC

This package is auto-updated.

Last update: 2024-12-13 00:16:20 UTC


README

Workflow Build Status Scrutinizer Code Quality Code Intelligence Status Build Status Coverage Status Quality Gate Status Bugs Security Rating Maintainability Rating Code Smells Lines of Code Coverage Technical Debt Reliability Rating Duplicated Lines (%) Vulnerabilities

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 exceptions
  • CommitType::OnResponse for requests, executes when request end without exceptions
  • CommitType::onHandled for consumers, executes when message successfully handled

Events

  • FRZB\Component\TransactionalMessenger\Event\DispatchSucceedEvent executes when message is dispatched
  • FRZB\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,
    ) {
    }
}

Resources

Contributions

Alt