Using exactly the same code, a high frequency haze

2019-09-08 00:24发布

问题:

I have the following code which is used to listen to various ringbuffers. Some are high frequency price data and some are low frequency trade data:

public static void main(String[] args) 
{       
    HazelcastInstance client = Hazelcast.newHazelcastInstance();    
    Ringbuffer<String> databuffer = client.getRingbuffer("data");

    long sequence = databuffer.headSequence();

    while(true)
    {
        String d = null;

        try 
        {
            d = databuffer.readOne(sequence);
            System.out.println(d);
        } 
        catch (InterruptedException e) 
        {
            StringWriter errors = new StringWriter();
            e.printStackTrace(new PrintWriter(errors));
            System.out.println(errors.toString());
        }

        sequence ++;
    }
}

The problem is the same code used for the low frequency trade data is working fine: autodiscovering the hazelcast cluster and when data is published into the ringbuffer it is read and acted on. However, for the high frequency data where lots of data is published to the ringbuffer in high volume, the reader above starts up, and autodiscovers the hazelcast cluster, but then does not read any data at all... Although on 1 occasion it did manage to work.

I have also tried with

long sequence = databuffer.tailSequence() + 1;

Any ideas about what might be going wrong?

回答1:

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

It works well.



标签: hazelcast hft