Hazelcast client not able to listen events : Hazelcast 3.6.2

216 views
Skip to first unread message

Prashant choudhary

unread,
Dec 7, 2016, 4:23:10 AM12/7/16
to Hazelcast
Hi, 

I am running multiple hazelcast members  with below configuration on two machines with the configuration below.

 <tcp-ip enabled="true">
        <member>192.168.0.111</member>
       <member>192.168.0.101</member>
 </tcp-ip>

I am starting the nodes with below code snippet
                String configFileLocation="hazelcast/member/hazelcast.xml";
cfg=new ClasspathXmlConfig(configFileLocation);
instance = Hazelcast.newHazelcastInstance(cfg);

I have three java clients using the configuration 
<cluster-members>
        <address>192.168.0.111</address>
           <address>192.168.0.101</address>
 </cluster-members>

I am starting the clients using code below
                                String configFileLocation="hazelcast/client/hazelcast-client.xml";
InputStream is = getClass().getClassLoader().getResourceAsStream(configFileLocation);
cfg = new XmlClientConfigBuilder(is).build();
instance = HazelcastClient.newHazelcastClient(cfg);

I am creating adding listeners for IMap as below

instance.getMap("MyMap").addEntryListener(new MyMapEntryListener(), true)

class MyMapEntryListener extends EntryAddedListener<String, String>{


@Override
public void entryAdded(EntryEvent<String, String> event) {

//Some operation

}
}

Entry may be added by any client/members to the Map and all clients need to process it. Initially, everything  works fine.



The issue occurs when I kill one node (Manually ctrl+c or kill -9 ). Sometimes my clients are not able to listen to the map even though there is at least one member is alive. The issue is random with clients, some clients work fine or some not.


I see the below exception in client logs

13:11:22.587  6556933 [http-apr-9090-exec-2] ERROR c.s.f.t.channel.StreamingTrading - Exception Listener can not be added
com.hazelcast.core.HazelcastException: Listener can not be added

or 

Caused by: java.util.concurrent.ExecutionException: java.io.IOException: Target :  Address[192.168.0.111]:5701 is not member. 
at com.hazelcast.client.spi.impl.ClientInvocationFuture.resolveResponse(ClientInvocationFuture.java:141) ~[hazelcast-all-3.6.2.jar:3.6.2]


I tried to add or  remove listener on hazelcast instance life cycle but did not help.

instance.getLifecycleService().addLifecycleListener(new HzLifecycleListener());

class HzLifecycleListener implements LifecycleListener {

@Override
public void stateChanged(LifecycleEvent event) {

switch (event.getState()) {
case SHUTDOWN:
//Hazelcast cluster is shutdown. Try to connect again
break;

case STARTED:

break;
case CLIENT_CONNECTED:
//Set the listener again 
break;
case CLIENT_DISCONNECTED:
//remove the listener 

break;
default:
break;
}

}

}



Can someone please guide me, how to manage the listeners on hazelcast client, so if any of the node in clusters goes down it will not impact it. What is the best possible approach to solving this issue?

ih...@hazelcast.com

unread,
Dec 12, 2016, 9:05:32 AM12/12/16
to Hazelcast
Hello,

You may be hitting this issue which is solved in the new releases. Can you upgrade and try?

Regards,
ihsan

ih...@hazelcast.com

unread,
Dec 12, 2016, 9:07:09 AM12/12/16
to Hazelcast
Forgot to attach the issue link. issue is: https://github.com/hazelcast/hazelcast/issues/8847

Regards,
ihsan

Prashant choudhary

unread,
Dec 19, 2016, 7:09:32 AM12/19/16
to Hazelcast
Thanks. I will upgrade to latest and try.
Reply all
Reply to author
Forward
0 new messages