I have created a single queue with daily rolling

2019-07-23 04:03发布

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.

2条回答
欢心
2楼-- · 2019-07-23 04:26

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());
    }

}
查看更多
仙女界的扛把子
3楼-- · 2019-07-23 04:49

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.

查看更多
登录 后发表回答