Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import amqp from 'amqplib/callback_api'
- amqp.connect('amqp://ARmachine:12345@localhost:5672/ARX', function(err, conn) {
- if (err) {
- console.error("[AMQP]", err.message)
- } else {
- console.log("[AMQP] connected")
- conn.createChannel(function(err, ch) {
- if (err) {
- console.error("[AMQP]", err.message);
- } else {
- console.log("[AMQP] Channel" + ch)
- ch.assertExchange('amq.topic', 'topic', {durable: true})
- console.log("[AMQP] Create Exchange")
- ch.assertQueue('mqtt.queue', {exclusive: true}, function(err, q) {
- console.log(" [*] Waiting for messages in %s. To exit press CTRL+C", q.queue)
- ch.bindQueue('mqtt.queue', 'amq.topic', 'mqtt.kereta')
- ch.consume(q.queue, function(msg) {
- console.log(" [x] %s", msg.content.toString())
- }, {noAck: true})
- });
- }
- })
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement