BAEL-995: resolved merge issues (#2255)
This commit is contained in:
parent
84956990b6
commit
78de955aac
|
@ -331,6 +331,11 @@
|
|||
<artifactId>datanucleus-xml</artifactId>
|
||||
<version>5.0.0-release</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.openhft</groupId>
|
||||
<artifactId>chronicle</artifactId>
|
||||
<version>3.6.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package com.baeldung.chronicle.queue;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.openhft.chronicle.Chronicle;
|
||||
import net.openhft.chronicle.ExcerptAppender;
|
||||
|
||||
public class ChronicleQueue {
|
||||
|
||||
public static void writeToQueue(
|
||||
Chronicle chronicle, String stringValue, int intValue, long longValue, double doubleValue)
|
||||
throws IOException {
|
||||
ExcerptAppender appender = chronicle.createAppender();
|
||||
appender.startExcerpt();
|
||||
appender.writeUTF(stringValue);
|
||||
appender.writeInt(intValue);
|
||||
appender.writeLong(longValue);
|
||||
appender.writeDouble(doubleValue);
|
||||
appender.finish();
|
||||
appender.close();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.baeldung.chronicle.queue;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import net.openhft.chronicle.Chronicle;
|
||||
import net.openhft.chronicle.ChronicleQueueBuilder;
|
||||
import net.openhft.chronicle.ExcerptTailer;
|
||||
import net.openhft.chronicle.tools.ChronicleTools;
|
||||
|
||||
public class ChronicleQueueTest {
|
||||
|
||||
@Test
|
||||
public void givenSetOfValues_whenWriteToQueue_thenWriteSuccesfully() throws IOException {
|
||||
File queueDir = Files.createTempDirectory("chronicle-queue").toFile();
|
||||
ChronicleTools.deleteOnExit(queueDir.getPath());
|
||||
|
||||
Chronicle chronicle = ChronicleQueueBuilder.indexed(queueDir).build();
|
||||
String stringVal = "Hello World";
|
||||
int intVal = 101;
|
||||
long longVal = System.currentTimeMillis();
|
||||
double doubleVal = 90.00192091d;
|
||||
|
||||
ChronicleQueue.writeToQueue(chronicle, stringVal, intVal, longVal, doubleVal);
|
||||
|
||||
ExcerptTailer tailer = chronicle.createTailer();
|
||||
while (tailer.nextIndex()) {
|
||||
assertEquals(stringVal, tailer.readUTF());
|
||||
assertEquals(intVal, tailer.readInt());
|
||||
assertEquals(longVal, tailer.readLong());
|
||||
assertEquals((Double) doubleVal, (Double) tailer.readDouble());
|
||||
}
|
||||
tailer.finish();
|
||||
tailer.close();
|
||||
chronicle.close();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue