Job Dispatch is a gem for dispatching jobs to workers in an asynchronous manner. Job Dispatch does not require any specific database, deliberately separating the storage of jobs from the dispatching of jobs to workers. Jobs are dispatched using ZeroMQ messages and workers can be implemented in any language.
Only the dispatcher needs to access the database. This decouples the workers from the database.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install job_dispatch
This gem uses rbczmq for sending messages, so its use is limited to platforms supporting this gem, namely a posix OS and MRI Ruby or Rubinius.
JRuby is not supported. Nor is Windows.
The built in Ruby worker has the same ruby requirements as the broker. However, additional workers can be implemented in any language on any platform provided they have access to ZeroMQ for messaging and a JSON library for reading/writing message payloads.
TODO: Write usage instructions here.
JobDispatch will work with any Job model class, provided it fulfils the following:
This method is for retrieving a single PENDING job from the database and atomically marking it as being IN PROGRESS so that it can not be received again. It is the dispatcher's Responsibility to update its status to completed/failed and schedule a retry if the retry_count > 0.
See the example model classes in the examples/ directory.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request
Licensed under MIT license, see LICENSE.txt.