首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用节点中的exchange发送消息-amqp

无法使用节点中的exchange发送消息-amqp
EN

Stack Overflow用户
提问于 2013-05-09 09:35:27
回答 1查看 791关注 0票数 0

这是我的代码:

代码语言:javascript
复制
var amqp = require('amqp');

var connection = amqp.createConnection( { host: 'localhost' },  { defaultExchangeName: 'testexchange' });
connection.on('ready', function () {
  console.log('Connected to rabbitmq');
  var exchange = connection.exchange('testexchange', {confirm:true}, function(exch){
    console.log('Created exchange: ' + exch.name);
    var queue = connection.queue('testqueue', { durable: true }, function(q) {
      exch.publish('testqueue', {a:1}, {}, function(error) {
        console.log(error); 
      });
    });
  });
});

我使用的是node 0.10.2和node-amqp 0.1.6,

我可以看到rabbitmqctl list_exchangestextexchange,但是没有rabbitmqctl list_queuestestqueue,有什么问题吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-05-09 22:40:58

你必须先定义它。

connection.queue('testqueue', { durable: true })

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16452957

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档