@tiledesk/tiledesk-multi-worker
v0.1.6
Published
Jobs-Worker-Queued is a job runner for Node.js. It allows you to define and schedule jobs (arbitrary functions) for execution in a Nodejs worker node using the Rabbit MQ server.
Downloads
650
Keywords
Readme
Jobs-Worker-Queued is a job runner for Node.js. It allows you to define and schedule jobs (arbitrary functions) for execution in a Nodejs worker node using the Rabbit MQ server.
Schema
Install
Run the follow command:
npm install --save jobs-worker-queued
Usage
Schedule a job
var JobManager = require("jobs-worker-queued");
var jobManager = new JobManager("amqp://YOUR_RABBIT_URI");
jobManager.publish(
{name: "job1", address: {city: "NY"}}
);
Run the jobs on the Worker
var JobManager = require("jobs-worker-queued");
var jobManager = new JobManager("amqp://YOUR_RABBIT_URI");
jobManager.run(function(data) {
console.log("run job here with payload", data)
});
Instantiate different jobs for different tasks
To properly exploit multi-worker, you need to instantiate JobManager using different queueName and topic for each different task.
The exchange can be unique.