我将 amqplib 与 node.js 一起使用,并试图确保我理解channels
.
这是来自 amqplib 文档:Channels are multiplexed over connections, and represent something like a session, in that most operations (and thereby most errors) are scoped to channels.
这是一些基本代码,我将在其中打开 amqp 连接、创建通道、交换和队列:
var amqp = require('amqp/callback_api');
var connection = amqp.createConnection({ host: "localhost", port: 5672 });
connection.on('ready', function () {
connection.createChannel(function(err, ch) {
ch.assertExchange('1', 'fanout', function(err, ok) {});
ch.assertQueue('a', {
exclusive: true,
durable: true
}, function(err, ok) {
});
});
在上面的代码中是否存在exchange '1'
并且queue 'a'
只存在于为其定义它们的通道上?我的意思是,如果我要发布a
要从另一个渠道交换的消息,交换a
仍然会路由消息吗?