沈斌
2016-12-23 ee567fd428466945ec8bb290308f3e26287dda63
queue.js
@@ -22,25 +22,11 @@
    });
};
module.exports.pushToScreen = function(data) {
module.exports.pushToMQ = function(ex, data) {
    amqp.connect(uri, function(err, conn) {
        conn.createChannel(function(err, ch) {
            var _ex = 'ex_data_screen';
            ch.assertExchange(_ex, 'fanout', { durable: false });
            ch.publish(_ex, '', new Buffer(JSON.stringify(data)));
        });
        setTimeout(function() {
            conn.close();
        }, 500);
    });
};
module.exports.pushToAlarm = function(data) {
    amqp.connect(uri, function(err, conn) {
        conn.createChannel(function(err, ch) {
            var _ex = 'ex_data_alarm';
            ch.assertExchange(_ex, 'fanout', { durable: false });
            ch.publish(_ex, '', new Buffer(JSON.stringify(data)));
            ch.assertExchange(ex, 'fanout', { durable: false });
            ch.publish(ex, '', new Buffer(JSON.stringify(data)));
        });
        setTimeout(function() {
            conn.close();