Disabling shutdown hook not working in client

228 views
Skip to first unread message

mark.h...@gmail.com

unread,
Jul 5, 2016, 3:10:09 PM7/5/16
to Hazelcast
I am trying to prevent my hazelcast client from shutting down via its shutdown hook, by adding a property to my configuration thus:

<hz:property name="hazelcast.shutdownhook.enabled">false<hz:property>

But the shutdown hook appears to still run anyway (as cache related activity in my shutdown hook fails saying "hz shutting down"). Am I doing something wrong? 

My expectation is that Hazelcast does nothing on shutdown in this scenario; I run my own shutdown hook, finish db/cache related activities and then directly call shutdown on the lifecycle manager.

Is this a valid expectation? Is this the correct property to use? Is there something else I need to set?

Thx
Mark

Enes Akar

unread,
Aug 5, 2016, 5:57:25 AM8/5/16
to Hazelcast
Hookdown is supported in hazelcast members not in clients.

As a workaround you can listen lifecycle for SHUTTING_DOWN state:
HazelcastInstance client = HazelcastClient.newHazelcastClient(config);
client.getLifecycleService().addLifecycleListener(new LifecycleListener() {
public void stateChanged(LifecycleEvent lifecycleEvent) {
if(lifecycleEvent.getState().equals(LifecycleEvent.LifecycleState.SHUTTING_DOWN)) {
System.out.println("shutting down");
}
}
});




--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+...@googlegroups.com.
To post to this group, send email to haze...@googlegroups.com.
Visit this group at https://groups.google.com/group/hazelcast.
To view this discussion on the web visit https://groups.google.com/d/msgid/hazelcast/b41c4df9-71ab-42e8-8655-df543358b220%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages