Reputation: 158
For the concept of taking back up , i need to copy data from one chronicle queue to another .
Would it be safe to do a directly copy the whole Bytes object from wire of one queue into another ?
something like
documentContext().wire().bytes().read(byte_buffer)
and then wrapping this byte_buffer into byte_store and writing as
documentContext().wire().bytes().write(byte_Store).
The reason i'm doing it is avoid any conversion back and forth into custom objects?
Upvotes: 2
Views: 234
Reputation: 533482
You can, but a simpler approach is to copy directly from one to the other.
ChronicleQueue inQ = SingleChronicleQueueBuilder.binary("in").build();
ExcerptTailer tailer = inQ.createTailer();
ChronicleQueue outQ = SingleChronicleQueueBuilder.binary("out").build();
ExcerptAppender appender = outQ.acquireAppender();
while(true) {
try (DocumentContext inDC = tailer.readingDocument()) {
if (!inDC.isPresent()) {
// not message available
break; // or pause or do something else.
}
try (DocumentContext outDC = appender.writingDocument()) {
outDC.wire().write(inDC.wire().bytes());
}
}
}
}
Upvotes: 1