我们的应用服务器 Server-A 一直在工作,并将数据(如果有)发送到其他代理服务器 Server-B 。这是一个例子:
//server-A.log
12 Mar 2015 18:28:20 - send data - http://server-b?user=dit&data=JSON_STRING
12 Mar 2015 18:28:20 - send data - http://server-b?user=lea&data=JSON_STRING
12 Mar 2015 18:28:20 - send data - http://server-b?user=alex&data=JSON_STRING
12 Mar 2015 18:28:20 - send data - http://server-b?user=tom&data=JSON_STRING
12 Mar 2015 18:28:20 - send data - http://server-b?user=luke&data=JSON_STRING
12 Mar 2015 18:28:20 - send data - http://server-b?user=dit&data=JSON_STRING
现在我想通过使用node.js和zeroMQ在 Server-B 上排队这些请求。
这是我的尝试... ZMQ队列:
// serverB-queue.js
var zmq = require('zmq'),
sock = zmq.socket('push');
sock.bindSync('tcp://127.0.0.1:3000');
console.log('Queue bound to port 3000');
//PROBLEM TODO: WAIT FOR REQUEST FROM SERVER-A AND PUT DATA INTO THE QUEUE
队列工作者接收并处理传入数据
// serverB-queue-worker.js
var zmq = require('zmq'),
sock = zmq.socket('pull');
sock.connect('tcp://127.0.0.1:3000');
console.log('Worker connected to port 3000');
sock.on('message', function(data){
// send data to user via websocket
});
所以我的问题是,我的serverB-queue.js如何监听来自服务器-A的请求?