Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Test code doesn't work #4

Open
MykytaLiashenko opened this issue Oct 16, 2015 · 2 comments
Open

Test code doesn't work #4

MykytaLiashenko opened this issue Oct 16, 2015 · 2 comments

Comments

@MykytaLiashenko
Copy link

I have just write test code with two servers (task and worker). I'm trying to connect, but nothing happened.
Code:
task.js

var rabbitHub = require('rabbitmq-nodejs-client');
var cluster = require('cluster');

cluster.setupMaster({
    exec:'worker.js'
});

cluster.fork();
console.log('forked');

var taskHub = rabbitHub.create({task:'task', channel:'myChannel'});
console.log('event');
taskHub.on('connection', function(hub){
    console.log('connection');
    var i = 0;
    setInterval(function(){
        hub.send('Hello' + i);
        i++;
    }, 1000);
});

taskHub.connect();
console.log('connected');

worker.js

var rabbitHub = require('rabbitmq-nodejs-client');

var workerHub = rabbitHub.create({task: 'worker', channel: 'myChannel'});

console.log('worker');
workerHub.on('connection', function(hub){
    hub.on('message', function(msg){
        console.log(msg);
        setTimeout(function(){
            hub.ack();
        }, 2000);
    }.bind(this));
});

workerHub.connect();
console.log('connection start');

IDE console log

/usr/local/bin/node task.js
forked
event
connected
worker
connection start

You can see, that task server runs before worker, but there is no connection.

@adrai
Copy link
Owner

adrai commented Oct 16, 2015

sorry this repo is not maintained anymore

@MykytaLiashenko
Copy link
Author

Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants