简体   繁体   English

编年史vs编年史队列包

[英]chronicle vs chronicle-queue package

I'm just getting started with chronicle queue - however I'm a bit confused on which API to use for reading/writing to the queue. 我刚刚开始记录编年史队列-但是,对于使用哪种API读取/写入队列,我有些困惑。 Specifically chronicle-queue-5 vs chronicle-3.5.* 尤其是编年史队列5编年史3.5。*

I've gone through this link which basically uses chronicle-queue API , but there are others like this which uses chronicle. 我已经通过了这个链接 ,基本上采用编年史队列API,但还有其他像这样它采用编年史。

What is the difference between these 2 below? 以下这2个有什么区别?

 Chronicle chronicle =  ChronicleQueueBuilder.indexed(_location).build();
 ExcerptAppender appender = chronicle.createAppender();
 appender.startExcerpt();
 appender.writeUTF("Hello World");

vs VS

ChronicleQueue queue = ChronicleQueue.singleBuilder(_location).build();
final net.openhft.chronicle.queue.ExcerptAppender appender = queue.acquireAppender();
 try (DocumentContext dc = appender.writingDocument()) 
 {
     dc.wire().write("hello").text("world " );
 }

The Javadoc documentation for ChronicleQueue and Chronicle seems very similar ChronicleQueueChronicle的Javadoc文档似乎非常相似

They are both writing a message to a chronicle queue. 他们俩都在将消息写入编年史队列。 I belive this 我相信这个

Chronicle chronicle =  ChronicleQueueBuilder.indexed(_location).build();
ExcerptAppender appender = chronicle.createAppender();
appender.startExcerpt();
appender.writeUTF("Hello World");

can now be written in chronicle queue 5 like this 现在可以像这样写在编年史队列5中

try (final ChronicleQueue queue = SingleChronicleQueueBuilder.binary("temp-dir").build()) {
   final ExcerptAppender appender = queue.acquireAppender();
   appender.writeText("Hello World");
}

Or if you wanted to store key : value data, like this 或者,如果您想存储keyvalue数据,像这样

try (final ChronicleQueue queue = SingleChronicleQueueBuilder.binary("temp-dir-2").build()) {
  final ExcerptAppender appender = queue.acquireAppender();
  try (DocumentContext dc = appender.writingDocument()) {
    dc.wire().write("hello").text("world");
  }
  DumpQueueMain.dump("temp-dir-2");
}

you can use 您可以使用

DumpQueueMain.dump("temp-dir-2");

to see how the data is stored, for example 例如,查看数据的存储方式

# position: 131360, header: 2
--- !!data #binary
hello: world

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM