Closed arden closed 7 years ago
Your question is: "Can I send a message before the connection is ready? “ the answer is No. But this time is very short you just have to care about it if you call instantly.
like senecajs can do it . call instantly. if i'm use senecajs in express or koa is very simple. because the client call have many time, but not only one time.
like this it's work ok too: server.js
'use strict'
const Hemera = require('./../packages/hemera')
const nats = require('nats').connect()
const hemera = new Hemera(nats, {
logLevel: 'info'
})
hemera.add({
topic: 'math',
cmd: 'add1'
}, function (req, cb) {
cb(null, req.a * req.b)
})
client.js
'use strict'
const Hemera = require('./../packages/hemera')
const nats = require('nats').connect()
const hemera = new Hemera(nats, {
logLevel: 'info'
})
hemera.act({
topic: 'math',
cmd: 'add1',
a: 2,
b: 2
}, function (err, resp) {
this.log.info(resp, 'Result')
})
@arden seneca doesn't rely on a messaging bus it doesn't need an agreement with third party. If you use seneca rabbitmq plugin you have to wait too until the connection is ready.
According to your example above: It can work but it is not guaranteed because its a timing issue.
client call code must in hemera.ready() method?
client call can't as:
directly?