Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/yiisolutions/yii2-queue

Yii2 Queue
https://github.com/yiisolutions/yii2-queue

amqp queue rabbitmq yii2 yii2-queue

Last synced: 5 days ago
JSON representation

Yii2 Queue

Awesome Lists containing this project

README

        

# Yii2 Queue

Extension for work with queues.

## Installation

Use composer

```
composer require "yiisolutions/yii2-migrations-advanced: *"
```

or add to composer.json require section:

```
"yiisolutions/yii2-migrations-advanced": "*"
```

## Configuration

First, we add to the configuration component.

```php
[
// ...
'queue' => [
'class' => 'yisolutions\queue\Queue',
'host' => 'localhost',
'port' => 5672,
'user' => 'guest',
'password' => 'guest',
'vhost' => '/',
],
// ...
],
// ...
];
```

## Send data

Next, to send data to the queue, we use the send() component method.

```php
'bar'];

/** @var Queue $queue */
$queue = Yii::$app->get('queue');
$queue->send('queue.name', $data);
```

## Receive data

We use the listen method to retrieve data.

```php
get('queue');
$queue->listen('queue.name', function(AMQPMessage $msg) use ($queue) {
// process data

// acknowledgment message
$queue->acknowledgmentMessage($msg);
});
```