0

我有一个简单的 Sencajs 和 RabbitMQ 设置。

听众

// foo.js (listener)
var seneca = require('seneca')();

seneca
  .use('seneca-amqp-transport')
  .add({
    "role": "foo",
    "cmd": "ping"
  }, (args, done) => {
     done(null, { result: "Hi FOO" });
  })
  .listen({
    type: 'amqp',
    pin: 'cmd:ping',
    url: 'amqp://guest:guest@localhost:5672'
  });// default - 10101 

客户

// app.js (client)

var seneca = require('seneca');

var foo = seneca()
  .use('seneca-amqp-transport')
  .client({
    type: 'amqp',
    pin: 'role:foo,cmd:ping',
    url: "amqp://guest:guest@localhost:5672"
  })
  .act('role:foo,cmd:ping', { message: 'Aha!' }, (err, response) => {
    if (err) console.error(err);
    else console.log(response);
  });

包.json

 ...
 "dependencies": {
    "seneca": "^3.17.0",
    "seneca-amqp-transport": "^2.2.0"
 }
...

当我运行这两个文件(节点 foo.js 和节点 app.js)时,app.js 会抛出以下错误:


 code: 'act_execute',
  seneca: true,
  package: 'seneca',
  msg:
   'seneca: Action cmd:ping,role:foo failed: Cannot read 
property \'pattern\' of undefined.',
  details:
   { message: 'Cannot read property \'pattern\' of undefined',
     pattern: 'cmd:ping,role:foo',
     fn:
      { [Function: transport_client]
        id:
         'pg:cmd:ping,role:foo,pin:role:foo,cmd:ping,type:amqp,url:amqp://guest:guest@0.0.0.0:5672' },
     callback: [Function],
     instance: 'Seneca/hhdy5dxvtas8/1574507599580/4684/3.17.0/-',
     callpoint: undefined,
     'orig$':
      TypeError: Cannot read property 'pattern' of undefined

但是,我可以清楚地看到(在 RabbitMQ 仪表板中)这些连接已建立......

这是我第一次玩 Senecajs 和 RabbitMQ ......我做错了什么?

4

1 回答 1

1

似乎将 var "{legacy: {meta:true}}" 添加到 Seneca 初始化程序解决了这个问题......

var seneca = require('seneca')({legacy: {meta:true}});
于 2019-11-23T15:53:07.940 回答