mkelcik / trf-consumer-base
Foundation for simple try-retry-fail MQ consumer
Installs: 676
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/mkelcik/trf-consumer-base
Requires
- php: ^7.1.3
- php-amqplib/php-amqplib: ^2.8
- symfony/event-dispatcher: ^4.2
Requires (Dev)
- phpstan/phpstan: ^0.11.4
This package is not auto-updated.
Last update: 2024-01-29 19:53:19 UTC
README
$connection = new PhpAmqpLib\Connection\AMQPStreamConnection('192.168.0.115', 5672, 'test', 'test', 'testing');
$driver = new \TRFDrivers\RabbitMQ\Driver($connection);
$consumer = new TRFConsumer\Consumer($driver, 'my-consumer-tag', 5);
// consume 'Testing' queue
$consumer->consume("Testing", function (TRFConsumer\Interfaces\MQMessage $message) {
// print msg content
var_dump($message->body());
//process msg ...
//Exception happened, message will be send to Testing-retry queue to be processed later, after 5 unsuccessful attempts will be send to Testing-fail queue
throw new \Exception("Process error, retry processing later");
});