Reputation: 1694
Hi I'm new to Chronicle Queue I have some doubts,
I want to create a ChronicleQueue with hourly rolling store files How can I create one. I creates the writer as follows,
ChronicleQueue queue = ChronicleQueueBuilder.single(chroniclePath).build();
ExcerptAppender appender = queue.acquireAppender();
Also I want to delete the files after the consumer completes reading, can I create a writer as follows for the same,
ChronicleQueue queue = ChronicleQueueBuilder.single(chroniclePath).storeFileListener(new StoreFileListener() {
@Override
public void onReleased(int cycle, File file) {
if (file != null) {
try {
file.delete();
} catch (Exception e) {
//log
}
}
}
}).build();
I want to know whether I'm doing in the proper way in this case.
Do we need to store the cycle number also in the reader for reading after a restart. Currently I'm storing index the only.
Upvotes: 1
Views: 782
Reputation: 533482
You can set the roll cycle in the builder
ChronicleQueue queue = ChronicleQueueBuilder.single(chroniclePath)
.rollCycle(RollCycles.HOURLY)
.build();
ExcerptAppender appender = queue.acquireAppender();
The listener can be used for deleting old files.
Typically, you only need to store the index for the reader (the cycle is part of the index)
Upvotes: 1