Is there a way to recover a registered service for client that unexpectedly shutdown?

  • 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?

  • Hi-

    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.