I am using node-celery. I just need to implement scheduling task so that Task can run on the background at the specific time. I am confused how can I define my task, currently I am defining task at the same file where I am implementing node-celery.
const celery = require('node-celery');
let client = celery.createClient({
CELERY_BROKER_URL: 'amqp://guest:guest@localhost:5672//',
CELERY_RESULT_BACKEND: 'amqp://'
});
In the above code, I just require node-celery and then created a client for amqp. Now I have to connect client and then call my task send_batch_email_using_mailgun with some parameter.
client.on('connect', function() {
client.call('send_batch_email_using_mailgun', {
campaign_data: campaign_data,
subject: subject,
template: template
}, {
eta: new Date(Date.now() + 120000)
});
});
Here _send_batch_email_using_mailgun_ is the task which is defined below the code in the same file with some parameter. I want that my function _send_batch_email_using_mailgun_ should be called after a certain time. My code is not working I think I have to define my task function elsewhere but I don't know where to define them. Do I need to create my task in python file? If yes then how can I import them in my js file?