yiisoft / yiisoft/yii2-queue

Redelivering

Open
#393 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status:ready for adoption type:bug
Dominant language
PHP
Stars
1.1k
Forks
285
Avg merge
5d 3h
Merged PRs (30d)
2

Description

What steps will reproduce the problem?
  1. Add some tasks to the queue.
  2. Run yii queue/listen and interrupt it by Ctrl+C.
What's expected?

The failed task (since RabbitMQ 2.7.0 ) must go to the head of the queue to keep the order of the tasks (https://www.rabbitmq.com/semantics.html#ordering).

What do you get instead?

The failed task goes to the back of the queue.

Additional info
Q A
Yii version 2.0.37
PHP version 7.2
Operating system Linux Alpine
RabbitMQ version 3.8.8
RabbitMQ Driver amqp_interop

Command:

<?php
namespace app\commands;


use app\jobs\bc\TestJob;
use Yii;
use yii\console\Controller;

class TestController extends Controller
{
    public function actionIndex(): void
    {
        for ($i = 0; $i < 5; $i++) {
            \Yii::$app->queue->push(Yii::createObject([
                'class' => TestJob::class,
                'id' => $i,
            ]));
        }
    }
}

Job:

<?php


namespace app\jobs\bc;


use yii\queue\JobInterface;

class TestJob implements JobInterface
{
    public $id;

    public function execute($queue)
    {
        print "$this->id\n";

        sleep(3);
    }
}

Output:

bash-5.0# php yii test
bash-5.0# php yii queue/listen
0
1
^C
bash-5.0# php yii queue/listen
2
3
4
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the yii queue/listen command and the amqp_interop RabbitMQ driver, reproducing the Ctrl+C sequence with the provided TestJob. Trace how interruption acknowledges or requeues the failed task; done means the interrupted task is redelivered before later queued tasks, consistent with RabbitMQ ordering.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, rabbitmq
Domain
backend, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.