Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var amqp = require('amqplib/callback_api')
- amqp.connect({
- protocol: 'amqp',
- hostname: 'localhost',
- port: 5672,
- username: 'ARmachine',
- password: '12345',
- locale: 'en_US',
- frameMax: 0,
- heartbeat: 0,
- vhost: '/ARX',
- }, function(err, conn) {
- if(err) {
- console.log("Error :" + err)
- }
- if(conn) {
- console.log("Creating Channel")
- conn.createChannel(function(err, ch) {
- console.log("Channel Created")
- ch.assertExchange('amq.topic', 'topic', {durable: true});
- console.log("Creating Exchange")
- ch.assertQueue('mqtt.queue', {exclusive: false}, function(err, q) {
- if(err) {
- console.log("Error Queue : " + err)
- }
- if(q) {
- console.log("Creating Queue")
- ch.bindQueue('mqtt.queue', 'amq.topic', 'mqtt.kereta')
- console.log("Waiting")
- ch.consume('mqtt.queue', function(msg) {
- console.log(" [x] %s", msg.content.toString())
- }, {noAck: true})
- }
- })
- })
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement