1

I have the following code on the hazelcast instance:

ITopic<String> topic;
HazelcastInstance hz = Hazelcast.newHazelcastInstance();
topic = hz.getTopic("data");

Data is repeatedly published to the topic

String event = "abc123"
topic.publish(event);

then on another machine on the LAN I run the client like this:

public class Listener implements MessageListener<String>
{
    ClientConfig clientConfig = new ClientConfig();     
    clientConfig.getNetworkConfig().addAddress("192.168.21.89:5701");
    HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig);

    ITopic<String> topic = client.getTopic("data");
    topic.addMessageListener(new Listener());  

    public void onMessage(Message<String> m) {
        System.out.println("onMessage");
    }
}

The client finds the hz node and starts, but doesn't see any data message on the iTopic. I thought hz instances and clients would autodiscover each other in default? Do I have to configure hz for the network somehow?

The client log shows:

2015-09-01 15:43:05,518 INFO Listener [main] In main()
In main()
Sep 01, 2015 3:43:05 PM com.hazelcast.core.LifecycleService
INFO: HazelcastClient[hz.client_0_dev][3.5] is STARTING
Sep 01, 2015 3:43:05 PM com.hazelcast.core.LifecycleService  
INFO: HazelcastClient[hz.client_0_dev][3.5] is STARTED  
Sep 01, 2015 3:43:06 PM com.hazelcast.core.LifecycleService  
INFO: HazelcastClient[hz.client_0_dev][3.5] is CLIENT_CONNECTED  
Sep 01, 2015 3:43:06 PM com.hazelcast.client.spi.impl.ClientMembershipListener  
INFO:  
Members [1] {  
    Member [192.168.21.89]:5701  
}
rupweb
  • 3,052
  • 1
  • 30
  • 57
  • Is the client (listener) already running at the time when you are publish events? – Jaromir Hamala Sep 01 '15 at 10:42
  • the publisher starts first... listener comes and goes when needed... sometimes publisher is stopped, listener stays up, publisher starts again, you know... But the onMessage code in the listener doesn't seem to get triggered. I haven't done any network config or anything else other than the code there. Do I need to? – rupweb Sep 01 '15 at 10:46
  • 1
    what version of Hazelcast you are using? Could you post a log from your client? – Jaromir Hamala Sep 01 '15 at 10:49
  • @JaromirHamala hi, posted the log in the question... – rupweb Sep 02 '15 at 13:41
  • I think the problem here is the data on the iTopic is high volume FX market data and somehow the iTopic can't get the initial handle on the stream. That's because similar code for low volume "trades" is seeing the trade data. The trade data isn't a continuous stream... – rupweb Sep 07 '15 at 08:44
  • This is related to http://stackoverflow.com/questions/32434762/using-exactly-the-same-code-a-high-frequency-hazelcast-ringbuffer-client-not-up – rupweb Sep 07 '15 at 09:26

1 Answers1

0

This was my own problem because I was not actually publishing the data I wanted to listen to. Aaargh!

rupweb
  • 3,052
  • 1
  • 30
  • 57