You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Andrea Cavalli 90b6c62da8 Fix synchronization 4 weeks ago
src Fix synchronization 4 weeks ago
.gitignore first commit 2 months ago
README.md Add readme 2 months ago
pom.xml Fix synchronization 4 weeks ago

README.md

FileQueue

Store messages on a disk queue in a fast producer, slow consumer scenario.

var tmpFile = Paths.get("temp.queue.bin");
try (var queue = new it.cavallium.filequeue.DiskQueueToConsumer<String>(tmpFile, new Serializer<String>() {
  @Override
  public byte[] serialize(String data) throws IOException {
    return data.getBytes(StandardCharsets.US_ASCII);
  }
}, new Deserializer<String>() {
  @Override
  public String deserialize(byte[] data) throws IOException {
    return new String(data, StandardCharsets.US_ASCII);
  }
}, text -> {
  System.out.println("Received: %s", text);
  
  // Return true if the message has been consumed, false to retry later
  return true;
})) {
  queue.startQueue();
    
  final var text = "test-message";
	
  while (true) {
    System.out.println("Emitted: %s", text);
    queue.add(text);
  }
}