我有一个简单的 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 ......我做错了什么?