Publication error event not sent when RabbitMQ is not up
See original GitHub issueHello,
I’m having trouble with RabbitMQ and error management. Here’s how to reproduce:
- Run container RabbitMQ
- Run my application with broker connect
- Shutdown RabbitMQ
- 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:
- Created 3 years ago
- Comments:12 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Publications
I’ve added a
paused
event and abort method as described aboveBroker 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
Published as rascal@9.4.0
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!