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
reusing redisClient fails to create jobs #119
Comments
Thanks for the report and snippet. I investigated a bit and I am not able to reproduce. Can you try the below snippet and let me know how it behaves: const Queue = require('bee-queue');
const redis = require('redis');
const redisClient = redis.createClient();
const producer1 = new Queue('my-queue', {
redis: redisClient,
isWorker: false,
});
const producer2 = new Queue('my-queue', {
redis: redisClient,
isWorker: false,
});
setInterval(() => {
producer1.createJob({ hello: 'world1' }).save();
producer2.createJob({ hello: 'world2' }).save();
}, 1000);
const worker = new Queue('my-queue', { redis: redisClient });
worker.process(async (job) => {
console.log('processed job', job.id, job.data);
}); This works for me as I would expect and after 2.01 seconds has printed:
I know in your sample you were using various options on both the Redis client and the queue/job, but those should be largely inconsequential here so I pared it down to just the core of sharing connections and enqueuing/processing jobs. If you find that some particular option or pattern causes trouble, let me know and I can take a closer look. |
Closing due to inactivity. Feel free to reopen. |
Hello @skeggse ! Before all, thanks for the good work <3 thanks! |
Sounds like you have the makings of a test-case? Would you be open to making a PR with a test that demonstrates this functionality? I can take a look, but it'd be much easier if I can just |
@skeggse Yeah I understand, not really practical for me neither as you have to manually restart your redis in local environment to reproduce the error... (from an external module)
(from the endpoint that needs to add the job)
So like this, it seems to be working but I'm not sure if it's a good idea to "recreate" the queue at each call. Wdyt? Thanks again :) |
You'll definitely want to avoid re-creating the queue. This:
Is new information, and makes sense - @LewisJEllis: I know we're moving to |
I see :/ Any way to reload the script directly in the retry_strategy, when redis reconnects? |
You could maybe do something like const bqScripts = require('bee-queue/lib/lua');
// inside some event handler
await bqScripts.buildCache(redisClient); This will check whether each script exists, and if it doesn't, it'll load it. |
Nice! Gonna try this right now :) |
Alright, so now it's working good after reconnect, but I'm still getting errors for jobs that were added during the connection loss... I'm not sure what to do in such case. |
Before anything: thanks for such amazing queue lib.
I have this issue: when I reference an existing redisClient to the queue redis configuration object like so:
The queue only saves jobs to Redis when I create a brand new connection using the queue connection parameters (but using an existing redisClient doesn't work). My redisClient works, as I can pull data from Redis normally, it's only the queue that is not able to save jobs on Redis when using my own redisClient.
Using:
The text was updated successfully, but these errors were encountered: