沈斌
2016-12-25 ddfcebeefdb5253244f82bd3794a711ee32bdd2b
删除冗余的代码,提升性能
2 files modified
22 ■■■■ changed files
queue.js 15 ●●●● patch | view | raw | blame | history
test.js 7 ●●●●● patch | view | raw | blame | history
queue.js
@@ -9,17 +9,10 @@
var ex = 'ex_data_dev1';
module.exports.publishMessage = function(data) {
    amqp.connect(uri, function(err, conn) {
        conn.createChannel(function(err, ch) {
            ch.assertExchange(ex, 'fanout', { durable: false });
            var message = '{"data": "' + data + '", "time":"' + moment().format('YYYY-MM-DD HH:mm:ss') + '"}';
            ch.publish(ex, '', new Buffer(message));
        });
        setTimeout(function() {
            conn.close();
            //process.exit(0)
        }, 500);
    });
    this.pushToMQ({
        data: data,
        time: moment().format('YYYY-MM-DD HH:mm:ss')
    })
};
module.exports.pushToMQ = function(ex, data) {
test.js
@@ -242,3 +242,10 @@
// var data = "5a0000010003accf23d4515f00000000000000000030003e198c00110814050300060034001400000004001f000301040200000000000000000003490056048c1f02000000000000000000000000003c5b";
// console.log(data.length);
var moment = require('moment');
var a = {
    data: {a:1, b:2},
    time: moment().format('YYYY-MM-DD HH:mm:ss')
};
console.log(JSON.stringify(a));