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.
Run the follow command:
npm install --save jobs-worker-queued
var JobManager = require("jobs-worker-queued");
var jobManager = new JobManager("amqp://YOUR_RABBIT_URI");
jobManager.publish(
{name: "job1", address: {city: "NY"}}
);
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)
});
To properly exploit multi-worker, you need to instantiate JobManager using different queueName and topic for each different task.
The exchange can be unique.