Skip to content

Commit 78de955

Browse files
aliraza995pivovarit
authored andcommitted
BAEL-995: resolved merge issues (eugenp#2255)
1 parent 8495699 commit 78de955

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

libraries/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,11 @@
331331
<artifactId>datanucleus-xml</artifactId>
332332
<version>5.0.0-release</version>
333333
</dependency>
334+
<dependency>
335+
<groupId>net.openhft</groupId>
336+
<artifactId>chronicle</artifactId>
337+
<version>3.6.4</version>
338+
</dependency>
334339
<dependency>
335340
<groupId>org.springframework</groupId>
336341
<artifactId>spring-web</artifactId>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.baeldung.chronicle.queue;
2+
3+
import java.io.IOException;
4+
5+
import net.openhft.chronicle.Chronicle;
6+
import net.openhft.chronicle.ExcerptAppender;
7+
8+
public class ChronicleQueue {
9+
10+
public static void writeToQueue(
11+
Chronicle chronicle, String stringValue, int intValue, long longValue, double doubleValue)
12+
throws IOException {
13+
ExcerptAppender appender = chronicle.createAppender();
14+
appender.startExcerpt();
15+
appender.writeUTF(stringValue);
16+
appender.writeInt(intValue);
17+
appender.writeLong(longValue);
18+
appender.writeDouble(doubleValue);
19+
appender.finish();
20+
appender.close();
21+
}
22+
23+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.baeldung.chronicle.queue;
2+
3+
import static org.junit.Assert.assertEquals;
4+
5+
import java.io.File;
6+
import java.io.IOException;
7+
import java.nio.file.Files;
8+
9+
import org.junit.Test;
10+
11+
import net.openhft.chronicle.Chronicle;
12+
import net.openhft.chronicle.ChronicleQueueBuilder;
13+
import net.openhft.chronicle.ExcerptTailer;
14+
import net.openhft.chronicle.tools.ChronicleTools;
15+
16+
public class ChronicleQueueTest {
17+
18+
@Test
19+
public void givenSetOfValues_whenWriteToQueue_thenWriteSuccesfully() throws IOException {
20+
File queueDir = Files.createTempDirectory("chronicle-queue").toFile();
21+
ChronicleTools.deleteOnExit(queueDir.getPath());
22+
23+
Chronicle chronicle = ChronicleQueueBuilder.indexed(queueDir).build();
24+
String stringVal = "Hello World";
25+
int intVal = 101;
26+
long longVal = System.currentTimeMillis();
27+
double doubleVal = 90.00192091d;
28+
29+
ChronicleQueue.writeToQueue(chronicle, stringVal, intVal, longVal, doubleVal);
30+
31+
ExcerptTailer tailer = chronicle.createTailer();
32+
while (tailer.nextIndex()) {
33+
assertEquals(stringVal, tailer.readUTF());
34+
assertEquals(intVal, tailer.readInt());
35+
assertEquals(longVal, tailer.readLong());
36+
assertEquals((Double) doubleVal, (Double) tailer.readDouble());
37+
}
38+
tailer.finish();
39+
tailer.close();
40+
chronicle.close();
41+
}
42+
43+
}

0 commit comments

Comments
 (0)