I'm using the SingleChronicleQueue implementation to keep track of the last element I processed from my data queue (also a SingleChronicleQueue).
In order to recover from a crash I need to read the last element in my state queue which will give me the index of the last processed data element. This works very well but I'm not satisfied with the way I find the last state element.
What I do right now is use the queue's firstCycle() and lastCycle() methods. Then I have to walk back and test if there are any elements in the cycle range given by these methods because the lastCycle() method will return an number corresponding to a cycle file which may or may not be present on disk. (Depends how long the application was down for)
Once the first cycle (with data) is found I read all elements until I reach the end. This gives me the last state element which has the last data index processed.
Is there a more elegant way to get at the last state element. I've tried the ExcerptTailer.toEnd() but it did not work in the case of (missing) cycle files..