Rated Executor

Created: 2013/10/06 14:53:58+0000 Revised: 2013/11/08 23:52:17+0000 Revisions:  3 2 1

A colleague was working on a demo that polled the Twitter API. He had to solve the problem where he needed to ensure that the poll did not exceed the rate limits imposed on polling. This problem can easily be generalised into a generic problem, accessing a resource at no greater than a fixed rate. I didn't know of a generalised solution to the problem so I decided to implement one. A rated executor.

A rated executor is an executor that executes tasks no faster than a fixed rate but as soon as it can otherwise. The ScheduledExecutorService in the Java API provides similar behaviour but the rate is task not executor specific.

I've implemented an executor that provides this functionality. It has support for Runnable and Callable tasks. It supports repeated execution of the same task and returns Future objects to represent the pending execution. It is available on GitHub and as a Maven artifact. The documentation is available at the Maven generated site.

For those of you interested in linked data for this project, see here: