const amqp = require('amqplib');
const amqplib_config = require('../../etc/config.json').amqplib_config
// 连接配置
const config = amqplib_config;
//生成一条消息
async function producerDirectMsg(exchange="exchange_system",msg) {
     // 创建连接
    const connection = await amqp.connect(config);
    // 创建通道
    const channel = await connection.createChannel();

    await channel.assertExchange(exchange, 'direct', { durable: true });
    
    channel.publish(exchange, 'new.msg', Buffer.from(JSON.stringify(msg)));
}