Update
This commit is contained in:
parent
dbcdbaafeb
commit
3a48d63b11
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
||||
<groupId>it.cavallium</groupId>
|
||||
<artifactId>filequeue</artifactId>
|
||||
<name>file queue project</name>
|
||||
<version>3.0.0</version>
|
||||
<version>3.0.2</version>
|
||||
<packaging>jar</packaging>
|
||||
<description>Light weight, high performance, simple, reliable and persistent queue</description>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -2,6 +2,7 @@ package it.cavallium.filequeue;
|
||||
|
||||
import com.squareup.tape2.QueueFile;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public final class DiskQueueToConsumer<T> implements IQueueToConsumer<T> {
|
||||
@ -10,10 +11,24 @@ public final class DiskQueueToConsumer<T> implements IQueueToConsumer<T> {
|
||||
private final QueueFile queueFile;
|
||||
|
||||
public DiskQueueToConsumer(Path file,
|
||||
boolean clear,
|
||||
Serializer<T> serializer,
|
||||
Deserializer<T> deserializer,
|
||||
QueueConsumer<T> consumer) throws IOException {
|
||||
QueueFile queueFile = new QueueFile.Builder(file.toFile()).build();
|
||||
QueueFile queueFile;
|
||||
try {
|
||||
queueFile = new QueueFile.Builder(file.toFile()).zero(false).build();
|
||||
if (clear) {
|
||||
queueFile.clear();
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
try {
|
||||
Files.deleteIfExists(file);
|
||||
} catch (Throwable ex2) {
|
||||
|
||||
}
|
||||
queueFile = new QueueFile.Builder(file.toFile()).zero(false).build();
|
||||
}
|
||||
this.queueFile = queueFile;
|
||||
this.queue = new QueueToConsumer<>(new SimpleQueueFile<>(queueFile, serializer, deserializer), consumer);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user