All Projects → swarrot → Swarrot

swarrot / Swarrot

Licence: mit
A lib to consume message from any Broker

Projects that are alternatives of or similar to Swarrot

Node Celery
Celery client for Node.js
Stars: ✭ 648 (+85.14%)
Mutual labels:  rabbitmq, queue
Yii Queue
Queue extension for Yii 3.0
Stars: ✭ 38 (-89.14%)
Mutual labels:  rabbitmq, queue
Machinery
Machinery is an asynchronous task queue/job queue based on distributed message passing.
Stars: ✭ 5,821 (+1563.14%)
Mutual labels:  rabbitmq, queue
Shuttle.esb
A highly extensible service bus implementation.
Stars: ✭ 71 (-79.71%)
Mutual labels:  rabbitmq, queue
Garagemq
AMQP message broker implemented with golang
Stars: ✭ 153 (-56.29%)
Mutual labels:  rabbitmq, queue
leek
Celery Tasks Monitoring Tool
Stars: ✭ 77 (-78%)
Mutual labels:  queue, rabbitmq
Yii2 Queue
Yii2 Queue Extension. Supports DB, Redis, RabbitMQ, Beanstalk and Gearman
Stars: ✭ 977 (+179.14%)
Mutual labels:  rabbitmq, queue
Laravel Queue Rabbitmq
RabbitMQ driver for Laravel Queue. Supports Laravel Horizon.
Stars: ✭ 1,175 (+235.71%)
Mutual labels:  rabbitmq, queue
Rabbitevents
Nuwber's events provide a simple observer implementation, allowing you to listen for various events that occur in your current and another application. For example, if you need to react to some event published from another API.
Stars: ✭ 84 (-76%)
Mutual labels:  rabbitmq, queue
python-asynchronous-tasks
😎Asynchronous tasks in Python with Celery + RabbitMQ + Redis
Stars: ✭ 37 (-89.43%)
Mutual labels:  queue, rabbitmq
Tesseract
A set of libraries for rapidly developing Pipeline driven micro/macroservices.
Stars: ✭ 20 (-94.29%)
Mutual labels:  queue, rabbitmq
Stompjs
Javascript and Typescript Stomp client for Web browsers and node.js apps
Stars: ✭ 324 (-7.43%)
Mutual labels:  rabbitmq
Letsmapyournetwork
Lets Map Your Network enables you to visualise your physical network in form of graph with zero manual error
Stars: ✭ 305 (-12.86%)
Mutual labels:  rabbitmq
Go Diskqueue
A Go package providing a filesystem-backed FIFO queue
Stars: ✭ 302 (-13.71%)
Mutual labels:  queue
Surging
Surging is a micro-service engine that provides a lightweight, high-performance, modular RPC request pipeline. The service engine supports http, TCP, WS,Grpc, Thrift,Mqtt, UDP, and DNS protocols. It uses ZooKeeper and Consul as a registry, and integrates it. Hash, random, polling, Fair Polling as a load balancing algorithm, built-in service gove…
Stars: ✭ 3,088 (+782.29%)
Mutual labels:  rabbitmq
Meiam.system
.NET 5 / .NET Core 3.1 WebAPI + Vue 2.0 + RBAC 企业级前后端分离权限框架
Stars: ✭ 340 (-2.86%)
Mutual labels:  rabbitmq
Mlib
Library of generic and type safe containers in pure C language (C99 or C11) for a wide collection of container (comparable to the C++ STL).
Stars: ✭ 321 (-8.29%)
Mutual labels:  queue
Jaas
Run jobs (tasks/one-shot containers) with Docker
Stars: ✭ 291 (-16.86%)
Mutual labels:  queue
Elves
开源自动化运维开发平台(IT Automatic Develop Platform)
Stars: ✭ 290 (-17.14%)
Mutual labels:  rabbitmq
Clearly
Clearly see and debug your celery cluster in real time!
Stars: ✭ 287 (-18%)
Mutual labels:  queue

Swarrot

Build Status Scrutinizer Quality Score Latest Stable Version Latest Unstable Version

Swarrot is a PHP library to consume messages from any broker.

Installation

The recommended way to install Swarrot is through Composer. Require the swarrot/swarrot package:

$ composer require swarrot/swarrot

Usage

Basic usage

First, you need to create a message provider to retrieve messages from your broker. For example, with a PeclPackageMessageProvider (retrieves messages from an AMQP broker with the pecl amqp package:

use Swarrot\Broker\MessageProvider\PeclPackageMessageProvider;

// Create connection
$connection = new \AMQPConnection();
$connection->connect();
$channel = new \AMQPChannel($connection);
// Get the queue to consume
$queue = new \AMQPQueue($channel);
$queue->setName('global');

$messageProvider = new PeclPackageMessageProvider($queue);

Once it's done you need to create a Processor to process messages retrieved from the broker. This processor must implement Swarrot\Processor\ProcessorInterface. For example:

use Swarrot\Processor\ProcessorInterface;
use Swarrot\Broker\Message;

class Processor implements ProcessorInterface
{
    public function process(Message $message, array $options)
    {
        echo sprintf("Consume message #%d\n", $message->getId());

        return true; // Continue processing other messages
    }
}

You now have a Swarrot\Broker\MessageProviderInterface to retrieve messages and a Processor to process them. So, ask the Swarrot\Consumer to do its job :

use Swarrot\Consumer;

$consumer = new Consumer($messageProvider, $processor);
$consumer->consume();

Using a stack

Heavily inspired by stackphp/builder you can use Swarrot\Processor\Stack\Builder to stack your processors. Using the built in processors or by creating your own, you can extend the behavior of your base processor. In this example, your processor is decorated by 2 other processors. The ExceptionCatcherProcessor which decorates your own with a try/catch block and the MaxMessagesProcessor which stops your worker when some messages have been consumed.

use Swarrot\Processor\ProcessorInterface;
use Swarrot\Broker\Message;

class Processor implements ProcessorInterface
{
    public function process(Message $message, array $options)
    {
        echo sprintf("Consume message #%d\n", $message->getId());
    }
}

$stack = (new \Swarrot\Processor\Stack\Builder())
    ->push('Swarrot\Processor\MaxMessages\MaxMessagesProcessor', new Logger())
    ->push('Swarrot\Processor\ExceptionCatcher\ExceptionCatcherProcessor')
    ->push('Swarrot\Processor\Ack\AckProcessor', $messageProvider)
;

$processor = $stack->resolve(new Processor());

Here is an illustration to show you what happens when this order is used:

this

Processors

Official processors

Create your own processor

To create your own processor and be able to use it with the StackProcessor, you just need to implement ProcessorInterface and to take another ProcessorInterface as first argument in constructor.

Deprecated processors & message providers / publishers

In order to reduce swarrot/swarrot dependencies & ease the maintenance, some processors & message providers / publishers have been deprecated in 3.x version. They will be deleted in 4.0.

If you use those deprecated classes you could create your own repository to keep them or we could create a dedicated repository under the swarrot organisation if you're willing to help to maintain them.

Message providers / publishers

  • SQS Message provider (in 3.5.0)
  • Stomp message providers (in 3.6.0)
  • Stomp message publishers (in 3.7.0)
  • Interop message publishers & providers (in 3.7.0)

Processors

  • SentryProcessor (in 3.5.0)
  • RPC related processors (in 3.5.0)
  • NewRelicProcessor (in 3.7.0)

Inspiration

License

Swarrot is released under the MIT License. See the bundled LICENSE file for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].