Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing a file based queue

I have an in memory bounded queue in which multiple threads queue objects. Normally the queue should be emptied by a single reader thread that processes the items in the queue.

However, there is a possibility that the queue is filled up. In such a case I would like to persist any additional items on the disk that would be processed by another background reader thread that scans a directory for such files and processes the entries within the files. I am familiar with Active MQ but prefer a more light weight solution. It is ok if the "FIFO" is not strictly followed (since the persisted entries may be processed out of order).

Are there any open source solutions out there? I did not find any but thought I would ping this list for suggestions before I embark on the implementation myself.

Thank you!

like image 272
serverman Avatar asked Jun 30 '10 23:06

serverman


People also ask

Which is the best implementation of queue?

It's better to use ArrayDeque instead of LinkedList when implementing Stack and Queue in Java. ArrayDeque is likely to be faster than Stack interface (while Stack is thread-safe) when used as a stack, and faster than LinkedList when used as a queue.

Does Java have a queue implementation?

Concurrent Queue ImplementationsThe java. util. concurrent package contains a set of synchronized Queue interfaces and classes. BlockingQueue extends Queue with operations that wait for the queue to become nonempty when retrieving an element and for space to become available in the queue when storing an element.

What is Bigqueue?

Big Queue. A big, fast and persistent queue based on memory mapped file. Notice, bigqueue is just a standalone library, for a high-throughput, persistent, distributed, publish-subscrible messaging system, please refer to Luxun, Luxun messaging system uses bigqueue internally as fast and persistent queue.


2 Answers

You could use something like SQLLite to store the objects in.

like image 162
Romain Hippeau Avatar answered Oct 09 '22 18:10

Romain Hippeau


Take a look at http://square.github.io/tape/, and its impressive QueueFile.

(thanks to Brian McCallister's "The Long Tail Treasure Trove" for pointing me at that).

like image 23
Aled Sage Avatar answered Oct 09 '22 17:10

Aled Sage