PHPackages                             mouf/utils.task.rabbitmq - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. mouf/utils.task.rabbitmq

ActiveMouf-library[Queues &amp; Workers](/categories/queues)

mouf/utils.task.rabbitmq
========================

This package is used to manage task in RabbitMq. It provides classes to create task in RabbitMq and consums it.

1.0.x-dev(10y ago)0608MITPHP &gt;=5.3.0

Since Jun 13Compare

[ Source](https://github.com/thecodingmachine/utils.task.rabbitmq)[ Packagist](https://packagist.org/packages/mouf/utils.task.rabbitmq)[ Docs](https://github.com/thecodingmachine/utils.task.rabbitmq)[ RSS](/packages/mouf-utilstaskrabbitmq/feed)WikiDiscussions Synced today

READMEChangelogDependencies (5)Versions (1)Used By (0)

Task manage by RabbitMq
=======================

[](#task-manage-by-rabbitmq)

This package is used to manage task in RabbitMq.

Installation
------------

[](#installation)

```
composer require thecodingmachine/utils.task.rabbitmq

```

Once installed, you need to register the [`TheCodingMachine\RabbitMQServiceProvider`](src/DI/RabbitMQServiceProvider.php) into your container.

If your container supports Puli integration, you have nothing to do. Otherwise, refer to your framework or container's documentation to learn how to register *service providers*. For Mouf, please see the last part.

### Required

[](#required)

This package can be used without RabbitMQ, but all task are executed in real time. To use RabbitMq please install it on your environment. After this add the RabbitMQ management to compute the task number in it.

```
rabbitmq-plugins enable rabbitmq_management

```

Introduction
------------

[](#introduction)

This service provider is meant to provide all the class used to create task.

Expected values / services
--------------------------

[](#expected-values--services)

This *service provider* expects the following configuration / services to be available:

NameCompulsoryTypeDescription`RABBITMQ_HOST`**yes**StringThe RabbitMQ host.`RABBITMQ_PORT`**yes**StringThe RabbitMQ user.`RABBITMQ_USER`**yes**StringThe RabbitMQ password.`RABBITMQ_PASSWORD`**yes**StringThe RabbitMQ port.`RABBITMQ_API_HOST`**yes**StringThe RabbitMQ management host.`RABBITMQ_API_PORT`**yes**StringThe RabbitMQ management port.`RABBITMQ_MAINQUEUE`**yes**StringThe RabbitMQ main queue name`RABBITMQ_ERRORQUEUE`*no*StringThe RabbitMQ error queue name`RABBITMQ_MAXPRIORITY`*no*IntegerThe RabbitMQ max priority`RABBITMQ_MAXTRIES`*no*IntegerThe RabbitMQ max tries`RABBITMQ_ENABLE`*no*BooleanThe RabbitMQ enableYou can edit the connection instance to add an error queue, if it's enable or not, the max tries by error and the priority.

Provided services
-----------------

[](#provided-services)

This *service provider* provides the following services:

Service nameDescription`Mouf\Utils\Task\Services\RabbitMQ\Connection`RabbitMQ connection`League\Tactician\CommandBus`Bus to manage the task type`Mouf\Utils\Task\Services\RabbitMQ\ConsumerService`Class to consum the RabbitMQ queue`Mouf\Utils\Task\Commands\RabbitMQ\ConsumerCommand`Class to add a command to consum the RabbitMQ queue`Mouf\Utils\Task\Services\RabbitMQ\ProducerService`Class to product a task in the RabbitMQ queueExtended services
-----------------

[](#extended-services)

This *service provider* does not extend any service.

Use it
------

[](#use-it)

You can add an error queue if you add the errorQueue name in the "Mouf\\Utils\\Task\\Services\\RabbitMQ\\Connection" instance.

After this, you can create your task. It's really simple, create a new instance with an extends to Mouf\\Utils\\Task\\Task. This class must be serialize. This class is to get your information, in this example to get a carId

```
