Chronicle Queue - 如何从裁缝那里读取自定义对象

ChronicleQueue - how to read custom object from tailer

我是 ChronicleQueue 的新手,我找不到一个直接的例子来说明如何从 tailer 中读回我的自定义对象。

public class MyData extends AbstractMarshallable

我的 class 包含一些字符串和数字,我可以使用 appender 写入队列,但没有直接的 api 调用。如何从 tailer.readDocument api 获取 MyData 对象?

尝试使用以下代码:

final DocumentContext context = queue.createTailer().readingDocument();
final MyData container = new MyData();
if (context.isPresent()) {
    context.wire().getValueIn().marshallable(container);
}

这假设附加是按以下方式执行的:

try (DocumentContext ctx = appender.writingDocument()) {
    ctx.wire().getValueOut().marshallable(myData);
}