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
Support re-start of HazelcastClient (after HazelcastInstanceNotActiveException) #4363
Comments
an hackish way to restart client:
|
Ali, many thanks for the quick response and the provided code. We will try it out in our integration tests. Any chance that such functionality will make it into the client? |
@gurbuzali, is it the same way to restart the hazelcast itself. as one we shutdown the hazelcast server(instance) we should find way to restart that. |
@gurbuzali, would you mind leaving more message for that ? If I were wrong to shutdown the hazelcastInstance from any kind of way. e.g from the press button of hazelcast mancenter, how could I restart such as I could catch the hazelcastInstanceNotActiveException and I could get the original configuration of hazelcast. how could I restart that or replace the bean in spring(if I use hazelcast-spring to create hazelcast instance). If you have any free time, would you mind leaving us more detail on how to restart hazelcast. for example, for the config hacked way to get from hazelcastInstanceProxy like this:
but I was failed that I could not directly replace the bean associated with hazelcastInstance though I could get the config and try to new the hazelcastInstance again. I need such help and instructions from hz team. |
@gurbuzali your provided solution does not seem to work at least with 3.8.3 release. Once a client switches to inactive state , client from HazelcastClientProxy is null |
Hi @mzapletal , @simpleusr , @bwzhang2011 Instead of restarting the client, I would propose that configure it so that it will never shutdown. And always be re-usable. And following will be the property to decide when to give up. If you want, you can set this practically infinite (Integer.MAX), or you can set a smaller value so that client will be closed for example after a week. This proposal was not practical before 3.9. Because all operations on a |
This feature is already available as explained by @sancar. |
Currently, clients may run into
HazelcastInstanceNotActiveException
and are shutting down in cases where this is not desired (e.g., reboot of the cluster, changing IP addresses ( #4349),...).In such cases, it may be desirable to get the client from a shutdown state back to a connecting state.
While it is easy in plain Java applications to just re-create the Hazelcast client, this gets almost impossible (or needs a lot of workarounds) when working with dependency injection. For example, when working with Spring, one creates a
HazelcastInstance
(shielding aHazelcastClientProxy
) in the container during startup of the application. When theHazelcastInstance
bean then gets into the shutdown state it is virtually destroyed (even it would be possible to reconnect later on). As a consequence, the whole application is not able to recover from this error without a restart.To overcome this issue, I would propose to support the restart of
HazelcastClientProxy
instances.The text was updated successfully, but these errors were encountered: