Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/null_payload_in_reserve
Browse files Browse the repository at this point in the history
  • Loading branch information
samdark authored May 22, 2023
2 parents 7832933 + 29d7450 commit 489d74d
Show file tree
Hide file tree
Showing 59 changed files with 331 additions and 254 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ Contributing to Yii2

- [Report an issue](https://github.com/yiisoft/yii2/blob/master/docs/internals/report-an-issue.md)
- [Translate documentation or messages](https://github.com/yiisoft/yii2/blob/master/docs/internals/translation-workflow.md)
- [Give us feedback or start a design discussion](http://www.yiiframework.com/forum/index.php/forum/42-general-discussions-for-yii-20/)
- [Give us feedback or start a design discussion](https://forum.yiiframework.com/c/yii-2-0/general-discussions/16)
- [Contribute to the core code or fix bugs](https://github.com/yiisoft/yii2/blob/master/docs/internals/git-workflow.md)
4 changes: 2 additions & 2 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
$header = <<<'EOF'
@link http://www.yiiframework.com/
@link https://www.yiiframework.com/
@copyright Copyright (c) 2008 Yii Software LLC
@license http://www.yiiframework.com/license/
@license https://www.yiiframework.com/license/
EOF;

$finder = PhpCsFixer\Finder::create()
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Yii2 Queue Extension Change Log

- Enh #372: Add ability to configure keepalive and heartbeat for AMQP and AMQP interop (vyachin)
- Enh #464: Delete property `maxPriority` (skolkin-worker)
- Enh #486: `SignalLoop::$exitSignals` now includes `SIGQUIT` (rhertogh)
- Enh #487: Add ability to push message with headers for AMQP interop driver (s1lver)


2.3.5 November 18, 2022
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ test71:
docker-compose run php71 vendor/bin/phpunit --colors=always -v --debug
docker-compose down
test70:
make clean
docker-compose build --pull php70
docker-compose run php70 vendor/bin/phpunit --colors=always -v --debug
docker-compose down
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Documentation is at [docs/guide/README.md](docs/guide/README.md).
Installation
------------

The preferred way to install this extension is through [composer](http://getcomposer.org/download/):
The preferred way to install this extension is through [composer](https://getcomposer.org/download/):

```
php composer.phar require --prefer-dist yiisoft/yii2-queue
Expand Down
17 changes: 17 additions & 0 deletions docs/guide-ja/driver-amqp-interop.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,20 @@ yii queue/listen
`listen` コマンドが無限にキューを調べ続けるデーモンを起動します。キューに新しいタスクがあると、即座に取得され、実行されます。
このコマンドを [supervisor](worker.md#supervisor) または [systemd](worker.md#systemd) によって適切にデーモン化するのが、
最も効率的な方法です。

## Working with headers in messages

The `setMessageHeaders` attribute can be used to send random headers to the queue along with the message.

For example:

```php
$queue = Yii::$app->queueTest;
$queue->setMessageHeaders = [
'header1' => 'header-value1',
'header2' => 'header-value2',
];
$queue->push(new TestJob());
```

> Note! Existing headers will not be overwritten by default.
2 changes: 1 addition & 1 deletion docs/guide-ja/driver-db.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ CREATE INDEX priority ON queue (priority);
マイグレーションが [src/drivers/db/migrations](../../src/drivers/db/migrations) にありますので、利用して下さい。

アプリケーションにマイグレーションを追加するためには、コンソールの構成ファイルを編集して、
[名前空間化されたマイグレーション](http://www.yiiframework.com/doc-2.0/guide-db-migrations.html#namespaced-migrations) を構成して下さい。
[名前空間化されたマイグレーション](https://www.yiiframework.com/doc-2.0/guide-db-migrations.html#namespaced-migrations) を構成して下さい。

```php
'controllerMap' => [
Expand Down
2 changes: 1 addition & 1 deletion docs/guide-ja/retryable.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
後者の場合においては、いくらか時間をおいて再試行できる方が良いでしょう。そうするための方法がいくつかあります。

> **Note:** 下記で説明する `ttr` 機能を使用するためには
> [PHP プロセス制御 (pcntl) 拡張](http://php.net/manual/ja/book.pcntl.php) がインストールされている必要があり、
> [PHP プロセス制御 (pcntl) 拡張](https://php.net/manual/ja/book.pcntl.php) がインストールされている必要があり、
> ワーカのコマンドが `--isolate` オプション (デフォルトで有効になっています) を使用する必要があります。
再試行のオプション
Expand Down
2 changes: 1 addition & 1 deletion docs/guide-ja/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Yii::$app->queue->on(Queue::EVENT_AFTER_ERROR, function ($event) {
イベントのロギング
------------------

queue コンポーネントは [Yii の内蔵ロガー](http://www.yiiframework.com/doc-2.0/guide-runtime-logging.html)
queue コンポーネントは [Yii の内蔵ロガー](https://www.yiiframework.com/doc-2.0/guide-runtime-logging.html)
を使ってキューのイベントを記録する `LogBehavior` を提供しています。

これを有効にするためには、queue コンポーネントを以下のように構成するだけです。
Expand Down
17 changes: 17 additions & 0 deletions docs/guide-ru/driver-amqp-interop.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,20 @@ yii queue/listen
- `--verbose`, `-v`: состояние обработки заданий выводится в консоль.
- `--isolate`: каждое задание выполняется в отдельном дочернем процессе.
- `--color`: подсветка вывода в режиме `--verbose`.

## Работа с заголовками в сообщениях

Для отправки произвольных заголовков в очередь, вместе с сообщением, можно использовать атрибут `setMessageHeaders`.

Например:

```php
$queue = Yii::$app->queueTest;
$queue->setMessageHeaders = [
'header1' => 'header-value1',
'header2' => 'header-value2',
];
$queue->push(new TestJob());
```

> Обратите внимание! Существующие заголовки не будут перезаписаны по умолчанию.
2 changes: 1 addition & 1 deletion docs/guide-ru/driver-db.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ CREATE TABLE `queue` (
Миграции смотрите в [src/drivers/db/migrations](../../src/drivers/db/migrations).

Расширение предлагает использовать
[миграции с неймспейсами](http://www.yiiframework.com/doc-2.0/guide-db-migrations.html#namespaced-migrations).
[миграции с неймспейсами](https://www.yiiframework.com/doc-2.0/guide-db-migrations.html#namespaced-migrations).
Чтобы добавить их в ваше приложение отредактируйте консольный конфиг:

```php
Expand Down
2 changes: 1 addition & 1 deletion docs/guide-ru/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Yii::$app->queue->on(Queue::EVENT_AFTER_ERROR, function ($event) {
-------------------

Этот компонент предоставляет `LogBehavior` для логирования событий, используя
[встроенный в Yii логгер](http://www.yiiframework.com/doc-2.0/guide-runtime-logging.html).
[встроенный в Yii логгер](https://www.yiiframework.com/doc-2.0/guide-runtime-logging.html).

Чтобы использовать его, просто подключите это поведение в конфигурации компонента, как показано в
примере:
Expand Down
17 changes: 17 additions & 0 deletions docs/guide-zh-CN/driver-amqp-interop.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,20 @@ daemonized via [supervisor](worker.md#supervisor) or [systemd](worker.md#systemd
- `--verbose`, `-v`: 详细模式执行作业。如果启用,将打印每个作业的执行结果。
- `--isolate`: 隔离模式。将在子进程中执行作业。
- `--color`: 在详细模式下高亮显示输出结果。

## Working with headers in messages

The `setMessageHeaders` attribute can be used to send random headers to the queue along with the message.

For example:

```php
$queue = Yii::$app->queueTest;
$queue->setMessageHeaders = [
'header1' => 'header-value1',
'header2' => 'header-value2',
];
$queue->push(new TestJob());
```

> Note! Existing headers will not be overwritten by default.
2 changes: 1 addition & 1 deletion docs/guide-zh-CN/driver-db.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ CREATE TABLE `queue` (

迁移文件存放在 [src/drivers/db/migrations](../../src/drivers/db/migrations).

添加迁移到您的应用程序,编辑控制台配置文件以配置[命名空间迁移](http://www.yiiframework.com/doc-2.0/guide-db-migrations.html#namespaced-migrations):
添加迁移到您的应用程序,编辑控制台配置文件以配置[命名空间迁移](https://www.yiiframework.com/doc-2.0/guide-db-migrations.html#namespaced-migrations):

```php
'controllerMap' => [
Expand Down
2 changes: 1 addition & 1 deletion docs/guide-zh-CN/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ Yii::$app->queue->on(Queue::EVENT_AFTER_ERROR, function ($event) {
--------------

此组件提供了使用日志 `LogBehavior` 记录队列事件
[Yii built-in Logger](http://www.yiiframework.com/doc-2.0/guide-runtime-logging.html).
[Yii built-in Logger](https://www.yiiframework.com/doc-2.0/guide-runtime-logging.html).

要使用它,只需按照以下方式配置队列组件:

Expand Down
17 changes: 17 additions & 0 deletions docs/guide/driver-amqp-interop.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,20 @@ yii queue/listen
The `listen` command launches a daemon which infinitely queries the queue. If there are new tasks
they're immediately obtained and executed. This method is most efficient when the command is properly daemonized via
[supervisor](worker.md#supervisor) or [systemd](worker.md#systemd).

## Working with headers in messages

The `setMessageHeaders` attribute can be used to send random headers to the queue along with the message.

For example:

```php
$queue = Yii::$app->queueTest;
$queue->setMessageHeaders = [
'header1' => 'header-value1',
'header2' => 'header-value2',
];
$queue->push(new TestJob());
```

> Note! Existing headers will not be overwritten by default.
2 changes: 1 addition & 1 deletion docs/guide/driver-db.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ CREATE INDEX priority ON queue (priority);
You can use migrations which are available from [src/drivers/db/migrations](../../src/drivers/db/migrations).

To add migrations to your application, edit the console config file to configure
[a namespaced migration](http://www.yiiframework.com/doc-2.0/guide-db-migrations.html#namespaced-migrations):
[a namespaced migration](https://www.yiiframework.com/doc-2.0/guide-db-migrations.html#namespaced-migrations):

```php
'controllerMap' => [
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/retryable.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ timeouts.
In the latter cases, it's good to be able to retry a job after some time. There are several ways to do this.

> **Note:** The `ttr` feature described below requires the
> [PHP Process Control (pcntl) extension](http://php.net/manual/en/book.pcntl.php) to be installed
> [PHP Process Control (pcntl) extension](https://php.net/manual/en/book.pcntl.php) to be installed
> and the worker command has to use the `--isolate` option (which is enabled by default).
Retry options
Expand Down Expand Up @@ -122,4 +122,4 @@ You should set an address of a Dead Letter Queue and a maximum number of attempt
[RabbitMQ]: driver-amqp.md
[AMQP Interop]: driver-amqp-interop.md
[AWS SQS]: driver-sqs.md
[Dead Letter Queue]: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html
[Dead Letter Queue]: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html
2 changes: 1 addition & 1 deletion docs/guide/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ Logging events
--------------

The component provides the `LogBehavior` to log Queue events using
[Yii's built-in Logger](http://www.yiiframework.com/doc-2.0/guide-runtime-logging.html).
[Yii's built-in Logger](https://www.yiiframework.com/doc-2.0/guide-runtime-logging.html).

To enable it, simply configure the queue component as follows:

Expand Down
1 change: 1 addition & 0 deletions src/cli/SignalLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class SignalLoop extends BaseObject implements LoopInterface
*/
public $exitSignals = [
15, // SIGTERM
3, // SIGQUIT
2, // SIGINT
1, // SIGHUP
];
Expand Down
23 changes: 21 additions & 2 deletions src/drivers/amqp_interop/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,20 @@ class Queue extends CliQueue
*/
public $commandClass = Command::class;

/**
* Headers to send along with the message
* ```php
* [
* 'header-1' => 'header-value-1',
* 'header-2' => 'header-value-2',
* ]
* ```
*
* @var array
* @since 3.0.0
*/
public $setMessageHeaders = [];

/**
* Amqp interop context.
*
Expand Down Expand Up @@ -351,8 +365,13 @@ protected function pushMessage($payload, $ttr, $delay, $priority)
$message->setDeliveryMode(AmqpMessage::DELIVERY_MODE_PERSISTENT);
$message->setMessageId(uniqid('', true));
$message->setTimestamp(time());
$message->setProperty(self::ATTEMPT, 1);
$message->setProperty(self::TTR, $ttr);
$message->setProperties(array_merge(
$this->setMessageHeaders,
[
self::ATTEMPT => 1,
self::TTR => $ttr,
]
));

$producer = $this->context->createProducer();

Expand Down
2 changes: 1 addition & 1 deletion src/drivers/sqs/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ protected function getClient()
];
} else {
// use default provider if no key and secret passed
//see - http://docs.aws.amazon.com/aws-sdk-php/v3/guide/guide/credentials.html#credential-profiles
//see - https://docs.aws.amazon.com/aws-sdk-php/v3/guide/guide/credentials.html#credential-profiles
$credentials = CredentialProvider::defaultProvider();
}

Expand Down
4 changes: 2 additions & 2 deletions tests/JobEventTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* @link http://www.yiiframework.com/
* @link https://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license https://www.yiiframework.com/license/
*/

namespace tests;
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* @link http://www.yiiframework.com/
* @link https://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license https://www.yiiframework.com/license/
*/

namespace tests;
Expand Down
4 changes: 2 additions & 2 deletions tests/app/PriorityJob.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* @link http://www.yiiframework.com/
* @link https://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license https://www.yiiframework.com/license/
*/

namespace tests\app;
Expand Down
4 changes: 2 additions & 2 deletions tests/app/RetryJob.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* @link http://www.yiiframework.com/
* @link https://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license https://www.yiiframework.com/license/
*/

namespace tests\app;
Expand Down
4 changes: 2 additions & 2 deletions tests/app/SimpleJob.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* @link http://www.yiiframework.com/
* @link https://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license https://www.yiiframework.com/license/
*/

namespace tests\app;
Expand Down
4 changes: 2 additions & 2 deletions tests/app/benchmark/Controller.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* @link http://www.yiiframework.com/
* @link https://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license https://www.yiiframework.com/license/
*/

namespace tests\app\benchmark;
Expand Down
4 changes: 2 additions & 2 deletions tests/app/benchmark/waiting/Action.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* @link http://www.yiiframework.com/
* @link https://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license https://www.yiiframework.com/license/
*/

namespace tests\app\benchmark\waiting;
Expand Down
4 changes: 2 additions & 2 deletions tests/app/benchmark/waiting/Job.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* @link http://www.yiiframework.com/
* @link https://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license https://www.yiiframework.com/license/
*/

namespace tests\app\benchmark\waiting;
Expand Down
4 changes: 2 additions & 2 deletions tests/closure/ClosureTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* @link http://www.yiiframework.com/
* @link https://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
* @license https://www.yiiframework.com/license/
*/

namespace tests\closure;
Expand Down
6 changes: 4 additions & 2 deletions tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ services:
dockerfile: tests/docker/php/5.6/Dockerfile
volumes:
- ./runtime/.composer56:/root/.composer
- ..:/code
dns: *php_dns
environment: *php_environment
depends_on: *php_depends_on
Expand Down Expand Up @@ -139,9 +140,10 @@ services:

# https://hub.docker.com/_/rabbitmq/
rabbitmq:
image: rabbitmq:3.9.10
image: rabbitmq:3.9.13-management-alpine
ports:
- 5673:5672
- "5673:5672"
- "15673:15672"
networks:
net: {}

Expand Down
Loading

0 comments on commit 489d74d

Please sign in to comment.