0

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?

rupweb
  • 3,052
  • 1
  • 30
  • 57
  • Can you create a unit tests that reproduces this behavior? I created the ringbuffer, so I can help you out with the issue. – pveentjer Sep 07 '15 at 09:39
  • Perhaps you are running into a StaleSequenceException? If the producers produce at a very high rate, it could be that the data for the reader is overwritten and then you run into this exception. So do you see an exception somewhere> – pveentjer Sep 07 '15 at 09:49
  • @pveentjer no don't see any exception the program as above autodiscovers the hz cluster then just waits. It's as if the databuffer.ReadOne method doesn't catch the latest publish event. – rupweb Sep 07 '15 at 16:49
  • Can you create a unit test that reproduces the problem? – pveentjer Sep 07 '15 at 19:19
  • @pveentjer thanks for your comments this was my own problem as was the related iTopic question... – rupweb Sep 08 '15 at 11:32

1 Answers1

0

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

It works well.

rupweb
  • 3,052
  • 1
  • 30
  • 57