Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout documentation help required! #4

Open
AhmedBHameed opened this issue Jun 21, 2020 · 0 comments
Open

Timeout documentation help required! #4

AhmedBHameed opened this issue Jun 21, 2020 · 0 comments

Comments

@AhmedBHameed
Copy link

AhmedBHameed commented Jun 21, 2020

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);
    });
  });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant