Search by

componenta / cqrs-retry

Retry middleware for Componenta CQRS commands

Maintainers

Package info

github.com/componenta/cqrs-retry

pkg:composer/componenta/cqrs-retry

Transparency log

Statistics

Installs: 15

Dependents: 0

Suggesters: 1

Stars: 0

Open Issues: 0

v2.0.2 2026-08-16 17:50 UTC

This package is auto-updated.

Last update: 2026-08-21 10:17:26 UTC


README

Retry middleware for CQRS v4 commands marked with #[Componenta\CQRS\Retry\Attribute\Retry].

composer require componenta/cqrs-retry

Register the CQRS and retry providers and add RetryMiddleware to the command middleware chain where transient failures may be retried.

return [
    new Componenta\CQRS\ConfigProvider(),
    new Componenta\CQRS\Retry\ConfigProvider(),
];

The provider registers Componenta\CQRS\Retry\Attribute\Retry in ConfigKey::COMMAND_METADATA_ATTRIBUTES and provides RetryMiddleware. The middleware requires the core CommandMetadataProviderInterface; it does not create an independent reflection fallback. With componenta/cqrs-app, retry metadata therefore follows the same development/compiled map semantics as the rest of CQRS.

Middleware ordering is controlled by the application. With transaction middleware, the two common compositions have different semantics:

RetryMiddleware
  TransactionMiddleware
    handler

creates a fresh transaction for every retry attempt. By contrast:

TransactionMiddleware
  RetryMiddleware
    handler

keeps all attempts inside one surrounding transaction. The package does not reject either topology; choose the one that matches the desired transaction semantics.

RetryableExceptionInterface marks transient exceptions that may be retried. Additional throwable classes can be configured explicitly in the middleware constructor. Retry attempts, delay, multiplier, maximum delay, and jitter are controlled by #[Retry] and middleware configuration.