redis-ccp-queue
Advanced tools
Comparing version
'use strict'; | ||
let id = process.argv[2]; | ||
const ccpq = require('../lib/index.js'); | ||
@@ -12,3 +10,3 @@ | ||
function handleMessage(data, done) { | ||
console.log('CONSUMER ' + id + ':'); | ||
console.log('CONSUMER:'); | ||
console.log(data); | ||
@@ -15,0 +13,0 @@ setTimeout(function () { |
'use strict'; | ||
const Redis = require('ioredis'); | ||
var inspect = require('eyes').inspector({ maxLength: false }); | ||
@@ -54,3 +53,9 @@ // ----------------------------------- | ||
this.shuttingDown = true; | ||
this.redis.disconnect(); | ||
console.log('shutting down'); | ||
try { | ||
this.redis.disconnect(); | ||
} catch (err) { | ||
} | ||
} | ||
@@ -97,2 +102,7 @@ } | ||
this.callback = callback; | ||
process | ||
.once('SIGINT', this.queue.shutdown) | ||
.once('SIGTERM', this.queue.shutdown); | ||
this.waitForNext(this); | ||
@@ -99,0 +109,0 @@ } |
{ | ||
"name": "redis-ccp-queue", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A simple and lightweight Competing Consumers Pattern Queue", | ||
@@ -11,4 +11,3 @@ "license": "MIT", | ||
"producer": "node ./examples/producer.js", | ||
"consumer1": "node ./examples/consumer.js 1", | ||
"consumer2": "node ./examples/consumer.js 2", | ||
"consumer": "node ./examples/consumer.js", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
@@ -15,0 +14,0 @@ }, |
@@ -56,8 +56,2 @@ # redis-ccp-queue | ||
} | ||
// add the following lines to your consumer to safely disconnect from Redis | ||
process | ||
.once('SIGINT', c.shutdown) | ||
.once('SIGTERM', c.shutdown); | ||
``` | ||
@@ -83,3 +77,3 @@ | ||
``` | ||
npm run consumer1 | ||
npm run consumer | ||
``` | ||
@@ -90,3 +84,3 @@ | ||
``` | ||
npm run consumer2 | ||
npm run consumer | ||
``` | ||
@@ -193,2 +187,5 @@ | ||
For the next major version I plan to implement a more reliable version where an additional list is used to track messages in transit. | ||
If a processes fails to deliver with in a specified amount of time, an item could be moved back to the original queue for delivery. | ||
## Version history | ||
@@ -198,2 +195,4 @@ | ||
| -------------- | -------------- | -------- | | ||
| 1.0.2 | 2016-02-29 | bug in dependencies | | ||
| 1.0.1 | 2016-02-29 | typos | | ||
| 1.0.0 | 2016-02-29 | initial release | | ||
@@ -200,0 +199,0 @@ |
Sorry, the diff of this file is not supported yet
44599
5.38%131
3.97%253
-0.39%