I currently put my objects in the Chronicle Queue as follows
ExcerptAppender appender = SingleChronicleQueueBuilder
.binary("/path_to_chronicle/")
.build()
.acquireAppender();
// Write
synchronized (appender) {
appender.writeText(object.toString());
}
Considering the class of "object" is extending AbstractMarshallable and has some ints, longs and strings, is there a more efficent way to pass it on to the queue? The way I currently read it off the queue is by calling Marshallable.fromString(text);
. I'm looking for a simple use case without too much code but still fast.
For writing, I would suggest you follow
try (final DocumentContext dc = appender.writingDocument()) {
dc.wire().write("msg").object(object);
}
and reading
try (DocumentContext dc = tailer.readingDocument()) {
if (dc.isPresent()) {
Object o = dc.wire().read("msg").object();
process(o);
}
}
This can be made more efficient, but it will be faster than what you have.