Rabbitmq 头交换amqplib或其他js库
我正在编写一个与基于RabbitMQ的软件系统接口的web应用程序。我是网络应用的新手,但我已经用meanstack编写了相当多的应用程序,我对此很满意。我找到了这个链接: 这表明有几个很好的替代库,比如bramqp和amqp.node,但是我还没有找到以下问题的答案。这些库中哪一个(如果有的话)允许我与基于头的交换进行交互?请注意,我很乐意将此作为上述原始链接的后续内容发布,但我不知道如何发布Rabbitmq 头交换amqplib或其他js库,rabbitmq,amqp,meanjs,Rabbitmq,Amqp,Meanjs,我正在编写一个与基于RabbitMQ的软件系统接口的web应用程序。我是网络应用的新手,但我已经用meanstack编写了相当多的应用程序,我对此很满意。我找到了这个链接: 这表明有几个很好的替代库,比如bramqp和amqp.node,但是我还没有找到以下问题的答案。这些库中哪一个(如果有的话)允许我与基于头的交换进行交互?请注意,我很乐意将此作为上述原始链接的后续内容发布,但我不知道如何发布 Howard我写了一篇教程,演示了下面的标题交换。不久的将来,bramqp中将添加类似的高级教程。
Howard我写了一篇教程,演示了下面的标题交换。不久的将来,bramqp中将添加类似的高级教程。这应该只打印其中一条消息
var bramqp = require('bramqp');
var async = require('async');
var net = require('net');
var socket = net.connect({
port : 5672
});
bramqp.initialize(socket, 'rabbitmq/full/amqp0-9-1.stripped.extended', function(error, handle) {
async.series([ function(seriesCallback) {
handle.openAMQPCommunication('guest', 'guest', true, seriesCallback);
}, function(seriesCallback) {
handle.queue.declare(1, 'header_test_queue');
handle.once('1:queue.declare-ok', function(channel, method, data) {
seriesCallback();
});
}, function(seriesCallback) {
handle.basic.consume(1, 'header_test_queue', null, false, true, false, false, {});
handle.once('1:basic.consume-ok', function(channel, method, data) {
handle.on('1:basic.deliver', function(channel, method, data) {
handle.once('content', function(channel, className, properties, content) {
console.log('got a message:');
console.log(content.toString());
});
});
seriesCallback();
});
}, function(seriesCallback) {
handle.exchange.declare(1, 'header_test_exchange', 'headers', function() {
seriesCallback();
});
}, function(seriesCallback) {
exchange_arguments = {
'x-match': {
type: 'Long string',
data: 'all'
},
wizard : {
type: 'Long string',
data: 'magic'
}
};
handle.queue.bind(1, 'header_test_queue', 'header_test_exchange', null, false, exchange_arguments, function() {
seriesCallback();
});
}, function(seriesCallback) {
handle.basic.publish(1, 'header_test_exchange', null, false, false, function() {
properties = {
headers: {
wizard : {
type: 'Long string',
data: 'magic'
}
}
};
handle.content(1, 'basic', properties, 'Hello World! with magic', seriesCallback);
});
}, function(seriesCallback) {
handle.basic.publish(1, 'header_test_exchange', null, false, false, function() {
properties = {
headers: {
wizard : {
type: 'Long string',
data: 'not magic'
}
}
};
handle.content(1, 'basic', properties, 'Hello World! without magic', seriesCallback);
});
}, function(seriesCallback) {
setTimeout(function() {
handle.closeAMQPCommunication(seriesCallback);
}, 10 * 1000);
}, function(seriesCallback) {
handle.socket.end();
setImmediate(seriesCallback);
} ], function() {
console.log('all done');
});
});