javascript - 在开玩笑退出时关闭 amqp 连接
问题描述
我有一个看起来类似于这个的笑话测试
const conn = amqplib.connect('amqp_url', {
timeout: 10 * 1000,
});
describe(`Testing.. `, (case) => {
test(`Test n`, (done) => {
conn
.then(function(conn) {
return conn.createChannel();
})
.then(function(ch) {
ch.assertQueue('')
.then(function(q) {
ch.bindQueue(q.queue, case.exchange, case.bKey)
.then(() => {
ch.consume(q.queue, function(msg) {
//veryfing logic goes here
done();
});
ch.publish(case.exchange, case.rKey, Buffer.from(case.orgMsg));
})
});
})
});
});
它可以工作,但测试后连接显然没有关闭。
有人可以解释一下在所有测试通过后我应该如何关闭与 amqp 的连接吗?
解决方案
推荐阅读
- python - Formsets + 多对多关系问题
- python - 在另一个笔记本的相对路径中运行带有空格的 Jupyter Notebook?
- android - 添加实现“android.arch.work:work-runtime:1.0.1”时出现重复类错误
- cassandra - cassandra 查询会是什么样子?
- r - 为什么我的条形图的所有频率都为 1?
- c# - 无法将字符串转换为 IEnumerable
- c# - WPF PrintDialog 设置为“Microsoft Print to PDF”无法覆盖现有文件
- hadoop - TDCH - batch.insert 模式 - 需要创建表访问?
- json - 创建 JSON 服务器层次结构
- vb.net - 将网络流中的数据读入数组