Using exactly the same code, a high frequency hazelcast ringbuffer client not updating but low frequency client is

↘锁芯ラ 提交于 2019-12-25 14:12:49

问题


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.



来源:https://stackoverflow.com/questions/32434762/using-exactly-the-same-code-a-high-frequency-hazelcast-ringbuffer-client-not-up

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!