Java FIFO queue with overflow to disk

I am / preparing an application based on the producer / consumer model In my case, there will be a producer generating millions of (non trivial) tasks, and there will be a configurable number of consumers

The communication between producers and consumers is basically queue - based However, I worry about memory consumption: it is conceivable that the number of tasks will exceed the available memory of the JVM So I want a queue implementation that only keeps the number of "top-x" queue items in memory and stores the rest on disk This does not have to be elastic because it does not need to continue after restarting the program

I've been searching, but I can't find a queue implementation that seems to be widely used (there seem to be some, which I call proof of concept implementations, but I'm worried about future support / continued development of these implementations) I've also looked at external message queuing applications, but (1) I don't want to run a second external process and (2) even embedding message agents in the same JVM process seems to be a bit "top heavy" on this requirement

Is anyone aware of any future oriented libraries that provide good support for this feature?

RGDS

Solution

Well, JMS seems to be an obvious solution I don't think you will find a reliable way to solve this problem, because JMS solves this problem and is a standard solution

However, please note that Java also has boundedqueues to solve this problem: dimensioning the queue to ensure that it will not fail due to oome when the queue is full, and the generator will be blocked when trying to put the message into the complete bounded queue until one of the consumers deletes the task from the queue

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>