Simply create multiple instances of the RSMQWorker pointing to the same queue.
Example:
var workers = [];
for (let i = 0; i < NUMBER_OF_WORKERS; i++) {
workers[i] = createWorker(i);
}
function createWorker(i) {
const worker = new RSMQWorker(QUEUE_NAME, {...});
worker.on("message", processMessage)
return worker;
}
Then you can use the auto-start option of the rsmq-worker or start them manually:
for (let i = 0; i < workers.length; i++) {
workers[i].start();
}
With this approach you will be processing multiple messages in parallel using one single Node.js instance. It improves the performance if your message processing logic involves some I/O.
For an additional level of parallelism, you can run the above code in multiple instances of Node.js, as mentioned in other answer.