From ee567fd428466945ec8bb290308f3e26287dda63 Mon Sep 17 00:00:00 2001
From: 沈斌 <bluelazysb@hotmail.com>
Date: Fri, 23 Dec 2016 22:36:48 +0800
Subject: [PATCH] 代码优化,重构消息推送函数

---
 queue.js |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/queue.js b/queue.js
index c377996..c1cb158 100644
--- a/queue.js
+++ b/queue.js
@@ -20,4 +20,16 @@
             //process.exit(0)
         }, 500);
     });
+};
+
+module.exports.pushToMQ = function(ex, data) {
+    amqp.connect(uri, function(err, conn) {
+        conn.createChannel(function(err, ch) {
+            ch.assertExchange(ex, 'fanout', { durable: false });
+            ch.publish(ex, '', new Buffer(JSON.stringify(data)));
+        });
+        setTimeout(function() {
+            conn.close();
+        }, 500);
+    });
 };
\ No newline at end of file

--
Gitblit v1.8.0