Is there a sophisticated Java WorkQueue API?
I am looking for a WorkQueue API offering the following f开发者_StackOverflow中文版eatures:
java.util.Queue
compatible- offers (optional) Set-semantic
- single- and batch-processing
- concurrency (of course)
- scheduling
- different processing policies
- wait until next scheduled execution
- pre-process, if batch size met
- delayed processing (minimum time in queue, before being processed)
- persistence (optional)
There are a lot of interesting implementations in the jdk, e.g. java.util.DelayQueue
which i could use. I just wanted to make sure i am not reinventing the wheel.
Have a look at Quartz Job Scheduler API
Quartz Features : http://www.quartz-scheduler.org/overview/features.html
I am not sure about its java.util.Queue compatibility. But it provides most of features related to Job scheduling and execution.
Are you still looking for an answer to accept?
I think your needs would best be met using java.util.concurrent
's executor framework. See the API (here's a good start). There's an excellent support community, you can find it at the concurrency-interest web site. If you're into dead trees, Java Concurrency in Practice (JCiP) provides an excellent resource.
The executor framework allows you to create tasks (in the form of Runnables or Callables), provides several schemes for synchronizing or otherwise ordering tasks with respect to one another.
Finally, the emerging ForkJoin (FJ) infrastructure is quite usable and may match your needs. API is here, a good paper is here, and an introductory article here.
Hope this helps.
JA
Short and straight answer - no. You have to roll out your own or you are just going to serve as a free tester for someone else's experiments. So at least you'll spend time making a system exactly for your needs, knowing all core parts and being in full control instead of taking in big and unknown dependency.
Although it does not have any scheduling functionality, the JDK has java.util.concurrent.SynchronousQueue
which may be useful.
精彩评论