lykmapipo / kue-scheduler

A job scheduler utility for kue, backed by redis and built for node.js
246 stars 47 forks source link

Query: To create a recurring job every day at 8AM particular timezone along with payload ? #112

Closed Arun-KumarH closed 6 years ago

Arun-KumarH commented 6 years ago

Hello,

I want to create a job that runs every day at particular time and using particular timezone along with payload.

let kue = require('kue-scheduler'); let Queue = kue.createQueue(); let job = Queue.createJob('unique_every', { timezone: 'Europe/Amsterdam' }) Queue.every('0 8 ', job);

But the createJob() takes only two parameters, so how can we add the payload data for the above case ?

mohamedali5 commented 6 years ago

Hey, I passed my timezone and the other variables in the same object parameter like:

const job = queue.createJob('unique_every', {
        id,
        timezone: 'Europe/Amsterdam',
    })
    .attempts(3)
    .priority('normal');

queue.every('* 16 * * *', job);

However, no matter what timezone I supply the job, it manages to process the job at my local machine time. For example, I supply 'Europe/Amsterdam' timezone and queue the job daily every minute at 4 PM. the job should be processed at 11 AM in New York but it also processes it at 4 PM. Did the timezone work in your example?

Arun-KumarH commented 6 years ago

Yes the timezone works for me.

Arun-KumarH commented 6 years ago

It was picking the local timezone of my machine earlier Europe/Berlin which was same as Amsterdam timezone. When I changed the time zone to EET i.e. Europe/Bucharest it still did process the job at the same time as my local machine. Below are the job details:

Job Data : { type: 'roomServiceNotificationJob', data: { payload: [ [Object] ], timezone: 'Europe/Bucharest', unique: 'unique_job_test', schedule: 'RECCUR', expiryKey: 'scheduling-srv:scheduler:tue_feb_27_2018_10_25_46_gmt_0100_cet', dataKey: 'scheduling-srv:scheduler:data:tue_feb_27_2018_10_25_46_gmt_0100_cet' }, priority: 0, progress: 0, attempts: { made: 0, remaining: 1, max: 1 }, reccurInterval: '0 0 11 *' }

So it seems that the timezone is not working at all. Could you please check it or let me know if I am missing something ?

Arun-KumarH commented 6 years ago

Figured out the issue was in _getNextDateFrom() and not using sendAt() of Cron.

Caveman07 commented 6 years ago

I would like to report that timezone is not working for me as well. const newJob = Queue .createJob(jobName, { timezone: 'America/Danmarkshavn' }) .attempts(1) .priority('normal') .removeOnComplete(true) .unique(jobName);

Cron job only follows local machine time.

Arun-KumarH commented 6 years ago

The issue is merged : https://github.com/lykmapipo/kue-scheduler/pull/114 waiting for new release.

deenaxoxo commented 5 years ago

What should I write in timezone: { }, if I want to use timezone of Line Island which is in Pacific Ocean.