question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Publication error event not sent when RabbitMQ is not up

See original GitHub issue

Hello,

I’m having trouble with RabbitMQ and error management. Here’s how to reproduce:

  1. Run container RabbitMQ
  2. Run my application with broker connect
  3. Shutdown RabbitMQ
  4. Trigger the function that send a message to RabbitMQ

Here is my code that is triggered:

async myFunc() {
  try {
    const publication = await this.broker.publish("toto", msg);
    publication
      .on("error", (err, messageId) => {
        console.error("Publisher error", err, messageId);
      })
      .on("success", messagesId => {
        console.log("success", messagesId);
      });
  } catch (error) {
      console.error("Catch error", error);
  }
}

Unfortunately, my console.error("Publisher error", err, messageId); is never executed. But somewhere else I have broker.on("error", console.error); just after the connect, and my error is logged here.

My problem is I’d like to know there’s an error when I’m executing my “myFunc” function. This function is executed in a API and I’d like to trace the error back to the user when RabbitMQ is inaccessible. Or even better, maybe there is a way to find the connection status for a vhost?

Thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
cressie176commented, May 4, 2020

Publications

I’ve added a paused event and abort method as described above

Broker Events

I’ve added vhost_initialised (although you still can’t get this during startup - it’s for reconnections only)

I’ve also added the vhost details to broker.error events

broker.on('error', (err, { vhost, connectionUrl }) => {
  // ...
});

Published as rascal@9.4.0

1reaction
AnthonySendracommented, May 2, 2020

OK, get it. Your example looks great to me. If I have both pause event and abort function, I’ll be able to do what I want!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to handle application failure after reading event from ...
DIgging through the Rabbit-MQ documentation I found this very useful example page for the different types of queues and message deliveries ...
Read more >
Publishers - RabbitMQ
When a published message cannot be routed to any queue, and the publisher set the mandatory message property to true, the message will...
Read more >
RabbitMQ tutorial - Reliable Publishing with Publisher Confirms
The method returns as soon as the message has been confirmed. If the message is not confirmed within the timeout or if it...
Read more >
Reliability Guide - RabbitMQ
Reliability Guide. Overview. This guides provides an overview features of RabbitMQ, AMQP 0-9-1 and other supported protocols related to data safety.
Read more >
Consumer Acknowledgements and Publisher Confirms
Should a client acknowledge the same delivery tag more than once, RabbitMQ will result a channel error such as PRECONDITION_FAILED - unknown delivery...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found