Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect behavior when adding a message to a queue from a job #305

Open
Gree-k opened this issue Jan 18, 2019 · 0 comments
Open

Incorrect behavior when adding a message to a queue from a job #305

Gree-k opened this issue Jan 18, 2019 · 0 comments
Labels
status:to be verified Needs to be reproduced and validated.

Comments

@Gree-k
Copy link

Gree-k commented Jan 18, 2019

What steps will reproduce the problem?

Trying push message to queue from job.

class NotificationJob extends BaseObject implements JobInterface
{
    public function execute($queue)
    {
        $instances = $this->getInstances();
        foreach ($instances as $instance) {
            $queue->push(new SenderJob($instance));
        }
    }
}
$config = [
    'bootstrap' => ['queuePush'],
    'components' => [
        'queuePush' => [
            'class' => \yii\queue\amqp_interop\Queue::class,
            'host' => $rabbit['host'],
            'port' => $rabbit['port'],
            'user' => $rabbit['user'],
            'password' => $rabbit['pass'],
            'driver' => yii\queue\amqp_interop\Queue::ENQUEUE_AMQP_LIB,

            'queueName' => 'push',
        ]
    ],
];

supervisor config


[program:yii-queue-push]
process_name=%(program_name)s_%(process_num)02d
command=/usr/bin/php /var/www/project/yii queue-push/listen
autostart=true
autorestart=true
user=www-data
numprocs=10
redirect_stderr=true
stdout_logfile=/var/www/project/scripts/log/yii-queue-push.log

What's expected?

I expect that after the NotificationJob, the queue will get some SenderJob and then start executing them.

What do you get instead?

All SenderJob are executed in the NotificationJob and additionally added to the queue several times.

If you put SenderJob in another queue, where a $instances contains one array element.
The SenderJob will be executed and 3 messages will be added to the queuePushSend, although the SenderJob should not be executed and 1 message should be added to the queuePushSend.

class NotificationJob extends BaseObject implements JobInterface
{
    public function execute($queue)
    {
        $instances = $this->getInstances();
        foreach ($instances as $instance) {
            Yii::$app->queuePushSend->push(new SenderJob($instance));
        }
    }
}

Additional info

Q A
Yii version 2.0.15.1
yii2-queue 2.1.0
PHP version 7.1.24
Operating system ubuntu16.04.1
@bizley bizley added the status:to be verified Needs to be reproduced and validated. label Jun 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:to be verified Needs to be reproduced and validated.
Projects
None yet
Development

No branches or pull requests

2 participants