java chronicle messages are not removed after reading

Viewed 684

I am trying to use Java Chronicle 1.9.2 to write/read messages. I know newer versions are available but have few questions before i invest more time in it.

I need to have the message removed once i read the Excerpt from the Chronicle. So if my reader starts again it doesn't go back to the beginning. Also message is of no use to me once i read it so want to remove it.

Is there an option to do it? i am trying following code and every time i start reader, i get all the messages again. Also Is there an option to put a Time to Live on message so it is automatically removed after certain time period.

WRITER -

        String tempPath = System.getProperty("java.io.tmpdir");
        String basePrefix = tempPath  + "chronicle";
        System.out.println("base prefix: " + basePrefix);
        Chronicle chr = new IndexedChronicle(basePrefix);
        final Excerpt excerpt = chr.createExcerpt();
        excerpt.startExcerpt(this.getmsgtext().length() + 4);
        excerpt.writeBytes(this.getmsgtext());
        excerpt.finish();
        chr.close();

READER -

        String tempPath = System.getProperty("java.io.tmpdir");
        String basePrefix = tempPath +  "chronicle";
        System.out.println("base prefix: " + basePrefix);
        Chronicle chr = new IndexedChronicle(basePrefix);
        final Excerpt excerpt = chr.createExcerpt();

        while (excerpt.nextIndex()) {
                System.out.println("Read string from chronicle: " + excerpt.readByteString());
        }
        chr.close();
1 Answers
Related