'How to send data from laravel to a redis queue implemented using Bull queue
I have implemented Bull queue in nestjs project but want producer to be a laravel project. I use following command to produce
Redis::command('zadd', ['bull:test:delayed', 1, $data]);
and at consumer use
@Processor('test')
export class ConsumerProcessor {
@Process({concurrency:13})
handle(j: Job<unknown>) {
this.logger.log(j.id);
}
}
The $data added at producer is accessible via job.id, how can I access it using job.data and have a unique id? What changes needs to be done at producer side?
Solution 1:[1]
Below code works:
A="some unique identifier";
Redis::command("hmset",['bull:<queuename>:<A>', "data" , json_encode($data)]);
Redis::command('zadd', ['bull:<queuename>:delayed', 1, A]);
Solution 2:[2]
I used https://github.com/HackThisSite/PHP-Bull-Scheduler to add jobs (works only with Predis)
Also tried https://github.com/ilzrv/php-bull-queue today to get phpredis support (requires php7.4+)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | shivamkss |
| Solution 2 |
