Is there a sophisticated Java WorkQueue API?

核能气质少年 提交于 2019-12-23 09:07:04

问题


I am looking for a WorkQueue API offering the following features:

  • 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.


回答1:


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




回答2:


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.




回答3:


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.




回答4:


Although it does not have any scheduling functionality, the JDK has java.util.concurrent.SynchronousQueue which may be useful.



来源:https://stackoverflow.com/questions/3491658/is-there-a-sophisticated-java-workqueue-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!