1

I create a tailerA and use tailerA read to the 100th message. And I create another tailerB

ChronicleQueue queue = SingleChronicleQueueBuilder.single("/home/data").rollCycle(rollCycles).build()

ExcerptTailer tailerA = queue.createTailer("A")
ExcerptTailer tailerB = queue.createTailer("B")

for(int i = 1;i < 101;i++){
   tailerA.read()  <- this is a simplified code for read
}


Use tailerB to read,it supposed to read from 1th to 100th one by one ,But what I need is to use tailerB reading start from 100th message. How can I use tailerA to copy the 100th information into tailerB?

1 Answers1

0

You can obtain the index an ExcerptTailer points to with

long index = tailerA.index();

and you can set the tailer to be this index with

boolean success = tailerB.moveToIndex(index);

Assuming this is successful both tailers will read the same Excerpt next.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
  • 1
    It solved my problem completely,but by the way ,I noticed that if tailerA has read to the end ,then tailerB.moveToIndex(index) will return false,I'm curious about why it designed to return false. – Asuka_Truth Jan 20 '22 at 06:07
  • @Asuka_Truth it returns false as there is no entry at that index, yet. – Peter Lawrey Jan 25 '22 at 16:25