简单的RabbitMQ

// send
let amqp = require('amqplib')
let conn = amqp.connect('amqp://localhost')
let channel = createChannel()
channel.assertQueue('haha')
channel.sendToQueue('heihei', 'msg')
channel.close()
// receive
let amqp = require('amqplib')
let conn = amqp.connect('amqp://localhost')
let channel = conn.createChannel()
channel.assertQueue('haha')
channel.consume('heihei', msg => {
    // do something
    channel.ack(msg)
})
The official documentation is here

猜你喜欢

转载自www.cnblogs.com/liqunblog/p/10008951.html