1

I have created a single queue with daily rolling. On the next day, I can't read the latest appended message. I found that the tailer index doesn't move to the latest cycle automatically after reading all messages in the previous cycle. By the way the java process was shut down at night and restarted on the next day.

I use Chronicle Queue V4.52.

Thanks.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
Hui Li
  • 51
  • 2
  • replicated similar issue here: https://stackoverflow.com/questions/52783626/reading-messages-in-chronicle-queue-tailer-v5-16-11-does-not-auto-move-the-ind – Sam Oct 15 '18 at 21:37

2 Answers2

0

This should work, we have tests which show messages are read from one cycle to the next.

Would you be able to include a test which reproduces this. There are quite a few unit tests you can use as examples.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
  • Thank you! I have 2 cq4 files that can not be read through. You can download the files from http://www.mf999.com/download/test.zip. The code is like this: SingleChronicleQueue queue = ChronicleQueueBuilder.single("e:/test").build(); ExcerptTailer tailer = queue.createTailer(); System.out.println(queue.lastCycle()); while(tailer.readBytes(b -> {System.out.println(b.readUtf8());})) { System.out.println(queue.rollCycle().toCycle(tailer.index()) + "#" + queue.rollCycle().toSequenceNumber(tailer.index())); } – Hui Li Aug 05 '16 at 11:03
  • Thank you. Chroncile Queue is a great thing. – Hui Li Aug 11 '16 at 12:49
0

this should now be fixed in the latest version

<dependency>
  <groupId>net.openhft</groupId>
  <artifactId>chronicle-bom</artifactId>
  <version>1.13.15</version>
  <type>pom</type>
 <scope>import</scope>
</dependency>

or if you prefer

 <dependency>
       <groupId>net.openhft</groupId>
       <artifactId>chronicle-queue</artifactId>
       <version>4.5.7</version>
 </dependency>

also see test case net.openhft.chronicle.queue.impl.single.SingleChronicleQueueTest#testReadingWritingWhenCycleIsSkipped

@Test
public void testReadingWritingWhenCycleIsSkipped() throws Exception {

    final Path dir = Files.createTempDirectory("demo");
    final RollCycles rollCycle = RollCycles.TEST_SECONDLY;

    // write first message
    try (ChronicleQueue queue = ChronicleQueueBuilder
            .single(dir.toString())
            .rollCycle(rollCycle).build()) {
        queue.acquireAppender().writeText("first message");
    }

    Thread.sleep(2100);

    // write second message
    try (ChronicleQueue queue = ChronicleQueueBuilder
            .single(dir.toString())
            .rollCycle(rollCycle).build()) {
        queue.acquireAppender().writeText("second message");
    }

    // read both messages
    try (ChronicleQueue queue = ChronicleQueueBuilder
            .single(dir.toString())
            .rollCycle(rollCycle).build()) {
        ExcerptTailer tailer = queue.createTailer();
        Assert.assertEquals("first message", tailer.readText());
        Assert.assertEquals("second message", tailer.readText());
    }

}
Rob Austin
  • 620
  • 3
  • 5