Asuka_Truth
Asuka_Truth

Reputation: 15

How to copy one tailer's read index to apply into another tailer using Chronicle Queue

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?

Upvotes: 1

Views: 87

Answers (1)

Peter Lawrey
Peter Lawrey

Reputation: 533530

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.

Upvotes: 1

Related Questions