enl/amqp-workers

This library provides more object-oriented way to create amqp workers and producers

v1.0.0 2016-09-08 09:16 UTC

This package is auto-updated.

Last update: 2024-11-29 04:36:02 UTC


README

Latest Version on Packagist Software License Build Status Scrutinizer Code Quality Total Downloads

All this library does is providing more fluent experience with AMQP. Original phpamqplib has very strange approach to its functions declarations.

I decided to create a tiny layer of abstraction which provides a bit more flexible interface:

$consumer = Consumer::factory($connection)
    ->withQueue(new Queue('consume_from'))
    ->withWorker($worker)
    ->run();

That is very short basic setup, Consumer has much more functions. Read the manual for more detailed description.

Features

  • More fluent and flexible interface than original php-amqplib library;
  • Very lazy approach, amqp-related stuff is called only when you call run or produce functions.

Install

composer require enl/amqp-workers

Usage

// Create AMQPConnection
$connection = new AMQPLazyConnection();

// We're using static `factory` function only for convenience with fluent interface
$consumer = Consumer::factory($connection)
    // set queue definition. all parameters are default
    ->withQueue(new Queue('consume_from'))
    // Worker is an object of WorkerInterface which handles given message body
    ->withWorker($worker)
    // declare and start consuming the queue
    ->run();

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

composer test

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email deadyaga@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.