Answer the question
In order to leave comments, you need to log in
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();
}
}
}
}
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 questionAsk a Question
731 491 924 answers to any question