Devas
Devas

Reputation: 1694

How to create a Chronicle Queue with Hourly rolling store files(cq4)

Hi I'm new to Chronicle Queue I have some doubts,

  1. 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();
    
  2. 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.

  1. 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

Answers (1)

Peter Lawrey
Peter Lawrey

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

Related Questions