O
O
ocupay2018-07-15 12:20:46
Yii
ocupay, 2018-07-15 12:20:46

Yii2-queue doesn't publish to redis channel, why?

There is something like this (simplified).
Entity inherits radish/activerecord
stage is rewritten (SET is executed, checked in redis-cli), and PUBLISH does not work.
According to user events, broadcast() works fine, but it doesn’t want to queue.
Any ideas?

class StatusJob extends BaseObject implements \yii\queue\JobInterface
{
    public $id;
    public $timer;

    public function execute($queue)
    {
        if ($this->timer - time() < 0) {
            $entity= Entity::find()->where(['id' => $this->id])->one();
            if ($entity->stage == 1) {
                $entity->stage = 2;
                $entity->update();
                $data = [
                    'id' => (int) $entity->id,
                    'timer' => $entity->timer - time(),
                    'stage' => (int) $entity->stage,
                ];

                (new SendToChannel(['data' => $data]))
                    ->setEvent('update')
                    ->toOthers()
                    ->broadcast();
            }

        }
    }
}

Also does not publish
Yii::$app->redis->executeCommand('PUBLISH', ["event" => "update", 'data' => $data]);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question