crutch/consumer-handler-retry

v1.0.0 2023-01-19 11:54 UTC

This package is not auto-updated.

Last update: 2024-11-22 03:34:22 UTC


README

consumer handler for retrying failed messages

Install

composer require crutch/consumer-handler-retry
<?php

/** @var Crutch\Producer\Producer $retryProducer */
/** @var Crutch\Consumer\ConsumerHandler $handler */
/** @var null|Crutch\RetryConsumerHandler\TopicStrategy\TopicStrategy $topicStrategy */
/** @var null|Crutch\RetryConsumerHandler\DelayStrategy\DelayStrategy $delayStrategy */
/** @var null|int $maxAttempts */

$retryHandler = new Crutch\RetryConsumerHandler\RetryConsumerHandler(
    $handler,
    $retryProducer,
    $topicStrategy,
    $delayStrategy,
    $maxAttempts
);

/**
 * if $handler throws exception, $retryProducer produced message to topic, defined by $topicStrategy 
 * with delay, calculated by $selayStrategy.
 */
$retryHandler->handle('message 1', 'one'); // handled by $topicOneHandler