问题
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.
回答1:
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.
回答2:
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());
}
}
来源:https://stackoverflow.com/questions/38589047/i-have-created-a-single-queue-with-daily-rolling