I have to deploy my client in an environment where it is possible to be shutdown unexpectedly, not allowing for proper cleanup steps to be taken. When the client starts up it automatically registers a few services to the broker so in the event of being shutdown and coming back up means both the original services it registered exist and a new duplicate set of services now exist until the original services TTL expires. Is there a strategy where i could either detect/remove the previously registered services that no longer have a client listening or perhaps re-attach to them if their TTL has not expired rather than creating new ones?
That is a great question. Unfortunately, there is not a way to recover an existing service. However, if a request is sent to a service that no longer exists, it will automatically be removed (is removed prior to TTL being reached).
So, one possible solution is that prior to registering your new service, you could ping (send a request) to any existing service instances (you can find these via a service query). This would ensure the services are still available (if they respond). Or, they will be removed from the fabric if the service is no longer available.
One approach we have discussed for some time was an automatic retry in the broker itself. So, if a request is sent, and a service is found to no longer exist, the broker would automatically direct that request at the next available service. Hopefully, that is something we can get added in an upcoming release.
Thanks for the very quick response, I'll try out your suggestion and eagerly await the retry feature!
Thank you for your time,
Absolutely! Please let me know if you need any help getting it to work.