1 Star 0 Fork 0

Gitee 极速下载 / popout

Create your Gitee Account
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/infobip/popout
Clone or download
Notice: Creating folder will generate an empty file .keep, because not support in Git


build_status maven_central License JavaDoc

Popout is a file-based queue for Java.

Don't forget to take a look at our benchmarks.



  • Java (minimal required version is 8);
  • Maven


Add dependency

Include the dependency to your project's pom.xml file:


or Gradle:

compile 'org.infobip.lib:popout:2.1.0'

Create a queue

Let's create a minimal config FileQueue instance:

FileQueue<String> queue = FileQueue.<String>synced().build();

The code above creates synced FileQueue implementation with default config. The queue data writes on the disk in a small files, named WAL-files. When the amount of that files is sufficiently (specified in the config, see below) that files merges to a big compressed file, the next portions of WAL-files to the next compressed-file and etc.

The differences between the FileQueue and the Java-default java.util.Queue interfaces are the following:

  • FileQueue.longSize - returns the number of elements in this queue with wide range, than int;
  • FileQueue.diskSize - tells the amount of bytes, which the queue takes on the disk;
  • FileQueue.flush - flushes all this queue's data to the disk;
  • FileQueue.compress - manually compress all WAL-files into a compressed file;
  • FileQueue.close - flushes and closes the files descriptors of the queue.

There are two main FileQueue implementations:

  • synced - every add operation is flushes on disk immediately and every poll reads the items from the disk directly. There is no buffers or something in-memory. It suits for cases, when you don't want to lose your data at all and you don't care about performance. It is the most reliable kind of the FileQueue;

  • batched - a concept of tail and head buffers is present here. You can specify a batchSize option, which tells to the queue builder how many elements could be store in memory, before writing to the disk. Writes and reads to/from the disk operations are batched and it boosts the queue's performance, but you always should remember that in case of unexpected crash you could lose your head or tail data. This kind of queue suits well when your need more performant queue and you don't afraid to lose some amount of data, or you are ready to control it your self by periodically invoking the flush method.

NOTICE: you also could instantiate WAL maxCount option and batchSize to Integer.MAX_VALUE and use flush and compress by yourself in fully manual manner.

More advanced FileQueue usage:

Queue<Integer> queue = FileQueue.<Integer>batched()
        // the name of the queue, used in file patterns
        // the default folder for all queue's files
        // sets custom serializer
        // sets custom deserializer
        // set up the queue's limits settings
        // restores from disk or not, during startup. If 'false' - the previous files will be removed
        // handler for corrupted data from disk
        .corruptionHandler(new MyCorruptionHandler())
        // WAL files configuration
            // the place where WAL files stores. Default is a queue's folder above
            // the maximum allowed amount of WAL files before compression
        // compressed files config
            // the place where compressed files stores. Default is a queue's folder above
            // the maximum allowed compressed file's size
        // the amount of elements in one WAL file. only batched queue option

Basic operations

Add some data to the queue to the end of the queue. FileQueue accepts a generic type of arbitrary length:


Read data at the head of the queue (without removing it):

String record = queue.peek();

In short, FileQueue implements Queue, Collection and Iterable interfaces and you are able to use all theirs methods:

// Queue's size
int queueSize = queue.size();

// Add many items
queue.addAll(asList("one", "two", "three"));

// Retrieves and removes the head of this queue,
String head = queue.poll();

// Remove all elements.

// Use queue's iterator
Iterator<String> iterator = queue.iterator();

Custom serialization and deserialization

By default, queue uses standard Java's serialization/deserialization mechanism, but you could override it by implementing Serializer and Deserializer:

Queue<String> queue = FileQueue.<String>synced()


These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.


For building the project you need only a Java compiler.

IMPORTANT: Popout requires Java version starting from 8

And, of course, you need to clone Popout from GitHub:

$> git clone https://github.com/infobip/popout
$> cd popout


For building routine automation, I am using maven.

To build the Popout project, do the following:

$> mvn clean package
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 35.491 s
[INFO] Finished at: 2019-01-18T23:25:12+03:00
[INFO] Final Memory: 50M/548M
[INFO] ------------------------------------------------------------------------

Running the tests

To run the project's test, do the following:

$> mvn clean test
[INFO] -------------------------------------------------------
[INFO] -------------------------------------------------------
[INFO] Results:
[INFO] Tests run: 32, Failures: 0, Errors: 0, Skipped: 0

Also, if you do package or install goals, the tests launch automatically.

Built With

  • Java - is a systems and applications programming language
  • Lombok - is a java library that spicing up your java
  • Junit - is a simple framework to write repeatable tests
  • AssertJ - AssertJ provides a rich set of assertions, truly helpful error messages, improves test code readability
  • Maven - is a software project management and comprehension tool


To see what has changed in recent versions of Popout, see the changelog file.


Please read contributing file for details on my code of conduct, and the process for submitting pull requests to me.


We use SemVer for versioning. For the versions available, see the tags on this repository.



This project is licensed under the Apache License 2.0 License - see the license file for details

Comments ( 0 )

Sign in for post a comment


Java file-based extremely fast and reliable FIFO queue. spread retract


No release

Gitee Metrics




load more
can not load any more