-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Add possibility of catch errors when message broker is down #11913
Comments
So far the only way to accomplish this is to use a custom strategy that extends the built-in transporter. Example: import { ServerMqtt } from '@nestjs/microservices';
import { MqttClient } from '@nestjs/microservices/external/mqtt-client.interface';
class MyCustomStrategy extends ServerMqtt {
bindEvents(mqttClient: MqttClient) {
super.bindEvents(mqttClient);
mqttClient.on('reconnect', () => console.log('Reconnecting...'));
}
}
// and later
const app = await NestFactory.createMicroservice<MicroserviceOptions>(AppModule, {
strategy: new MyCustomStrategy({
url: 'mqtt://0.0.0.0:1883',
}),
}); |
Thanks, @kamilmysliwiec But it would be great if it were mentioned in the docs. |
@vahidvdn feel free to propose an improvement to the docs here: https://github.com/nestjs/docs.nestjs.com via pull request |
@micalevisk I will do it asap. I have a section in my mind in the overview menu right after handling timeouts (maybe called handling events) and refer to |
Instead of creating a new page, we should add a dedicated section to each transporter as the implementation can vary considerably |
@kamilmysliwiec That makes perfect sense to me. But it would be great if you could mention the overall solution in the overview menu regarding By the way, it was just an idea. I will try to add them to the mqtt secotion at least, and adding some overall information to the overview menu is your call. Thanks |
Let's track this here #14142 |
Is there an existing issue that is already proposing this?
Is your feature request related to a problem? Please describe it
In express based applications, we can catch the broker error as following:
While it seems this is not possible in NestJS.
Describe the solution you'd like
I tested the global filters but didn't work. Similar way or any other way could be very nice.
Teachability, documentation, adoption, migration strategy
No idea for now
What is the motivation / use case for changing the behavior?
As I mentioned, I need to send a message to Sentry and log in my system, whenever the broker is down.
The text was updated successfully, but these errors were encountered: