-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Work Queue like in rabbitmq? #118
Comments
the work queue backpressure mechanism isn't perfect, but you can use node streams Anyway, if you want to checkout PUSH/PULL, create two files:
it's best to get the workers ready first. to get them going, run the file below a few times. open some new tabs on your terminal and execute this in each one: // pull.js
// a worker process
var nano = require('nanomsg');
var pull = nano.socket('pull');
pull.connect('tcp://127.0.0.1:7789');
pull.pipe(process.stdout);
console.log('waiting...'); then open one last tab and run the push socket like: // push.js
// source of work
var work = 0;
var nano = require('nanomsg');
var push = nano.socket('push');
push.bind('tcp://127.0.0.1:7789');
setInterval( send, 100 );
function send(){ push.send('counted work:' + ++work + '\n'); } make sure to switch back to the other tabs and kill some of the worker processes. or bring them back online too if you want, just note the change in rate of consumption. |
One thing that puzzles me is when you think about adding persistence(like Redis) with nanomsg...if every job is being sent to Redis, why not do everything in Redis and ditch nanomsg? |
Sure, with Redis, you have a hub and spoke model. The power of nanomsg is the various network topologies that don't require a central broker. |
Is there a way to use nanomsg as Work Queue like https://www.rabbitmq.com/tutorials/tutorial-two-javascript.html?
The text was updated successfully, but these errors were encountered: