-
Notifications
You must be signed in to change notification settings - Fork 7
Set env.MSB_BROKER_RECONNECT to false by default #200
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
Comments
Consider this as a minor fix for the 1.x version. Still backward compatible but brings a new behavior in case of connectivity issue. The same fix should be added to 2.x version as well. |
duplicates #56 |
Hi @shumsky, I agree that an app/module doing things silently without notifying is a very annoying behaviour. Maybe I'm going a little bit out of the scope. To stuck with the initial issue: I would disable retry if that is working silently by default and try to document really well that. |
Hi @Kumjami, To me, MSB should have retry, whether it's provided by the underlying AMQP library or implemented by ourselves on the adapter level. But it looks like the current solution brings more harm than good. So maybe it's worth to disable it by default (BTW, it is disabled by default in the amqp-coffee itself) and create an issue for implementing a better solution which could then become the default behavior. As you suggested, we could also consider replacement of the amqp-coffee with the amqplib within the scope of the new solution. I like the way the retry is done in the RabbitMQ Java client. msb-java is aligned with it. We could consider implementing it in MSB for Node. |
@shumsky I completely agree. |
I compared default behaviour of three AMQP libraries in a few different scenarios of connection loss:
The worst behaviour is amqp-coffee with RECONNECT=true, where silent retry is applied. And a good behaviour, to me, is amqp-client for Java, which we could consider implementing in MSB and which is also an official RabbitMQ client for Java. Summing it up. Due to amqp-coffee API being not fluent enough, it is hard to adjust its retry mechanism without workarounds in MSB or microservices. We can do next sequence of steps:
The first step is the solution I initially proposed in this issue. Once we encounter a connection loss, we would let the microservice die and delegate recovery to the process supervisor (e.g. PM2). The same approach is also advocated by the creator of the amqplib for Node: amqp-node/amqplib#25 (comment) |
Hi @shumsky, great report. So I understand that official amqp libraries has different behaviours in Java and Node. This is something a little bit confusing. In my opinion we should try to have the logic a the same place for different implementations. So, if in java the retry is at amqp lib level, in Node it should be also at that level, and not in MSB logic itself. So maybe it would be a possibility to open a PR to add retry and logging at amqplib or to add the logging while retrying at amqp-coffee. Do you think that could be possible? |
@Kumjami Agree that the retry approach should be aligned in Java and Node versions of MSB. I think opening a PR to either amqplib or amqp-coffee would be the right way. Though it might take time. The maintainer of the amqp-coffee hasn't been responsive for last few weeks. And the maintainer of amqplib seems to have concerns regarding retry functionality as a corresponding issue has been unresolved since 2013. |
Hi all, https://docs.newrelic.com/docs/agents/nodejs-agent/supported-features/message-queues |
Thanks for the update. It is certainly one more good point for migrating to amqplib. |
All details regarding migration to amqplib will be described there #204 |
Hello,
amqp-coffee library which the AMQP adapter is based on provides a feature of connection retry. MSB enables that feature by default:
The drawback of that feature is that the retry is done silently without logging an error or emitting any events. If a microservice which consumes a queue via MSB is misconfigured and fails to establish a connection with the borker, it will retry forever without giving any signs of the problem.
I propose to disable connection retry in MSB by default, namely set
MSB_BROKER_RECONNECT
to false. So that the microservice would terminate with an error printed to stderr once the connection fails to be established or is lost. In that case the problem would be immediately detected.When the application crashes, PM2 will try to restart the it with limited number of attempts. If the connection problem is temporary and may be gone in a moment, the microservice could be healed after a restart. If the connection problem is permanent, PM2 will exhaust the number of attempts and set the microservice to the errored state.
What do you think about that?
The text was updated successfully, but these errors were encountered: