Timeout documentation help required!
Opened this issue · 0 comments
AhmedBHameed commented
Due to the documentation here, I assume that i get an error as timeout or ?
What i need to do is terminate the message when time is out.
I tried the following configuration which not sure if I set it up correctly OR understand timeout
correctly!
Sender
hydraExpress.init(HydraConfig, () => {
const from = `${hydra.getServiceName()}@${hydra.getInstanceID()}`;
const greetingMessage = hydra.createUMFMessage({
to: 'authentication-service:/',
from: from,
timeout: 1,
body: {
greeting: `Eh, braddah, ${from} here, howsit!`,
},
});
let i = 1;
api.get('/bus-test', (req, res) => {
hydra.once('message', message => {
res.send(`<pre>${JSON.stringify({count: ++i, message}, null, 4)}</pre>`);
});
hydra.sendMessage(greetingMessage);
});
hydraExpress.registerRoutes({
'/': api,
});
});
Receiver
hydraExpress.init(HydraConfig, () => {
const from = `${hydra.getServiceName()}@${hydra.getInstanceID()}`;
function message() {
return `ECHO ${from}, Hello!!`;
}
hydra.on('message', _message => {
const echoMessage = hydra.createUMFMessage({
to: 'core-service:/',
from: from,
timeout: 1,
body: {
greeting: message(),
},
});
setTimeout(() => {
hydra.sendMessage(echoMessage);
}, 3000);
});
});