techwhizbang / jruby-quartz
- Source
- Commits
- Network (1)
- Issues (0)
- Downloads (3)
- Wiki (1)
- Graphs
-
Tree:
ae1e49c
Nicholas Zalabak (author)
Fri Jul 31 17:07:16 -0700 2009
commit ae1e49cfc9c64717a2cf9171e3f4a6787f5c41b9
tree 7d8cb5356520bac28a6192a6c74501d9687af2b7
parent 781d3b11e74301a9ec29bdfd5d0c4d06be3fc6ae
tree 7d8cb5356520bac28a6192a6c74501d9687af2b7
parent 781d3b11e74301a9ec29bdfd5d0c4d06be3fc6ae
| name | age | message | |
|---|---|---|---|
| |
LICENSE | Wed Feb 11 20:42:39 -0800 2009 | |
| |
README | Fri Jul 31 17:07:16 -0700 2009 | |
| |
Rakefile | ||
| |
jruby-quartz.gemspec | ||
| |
lib/ | ||
| |
test/ | Fri Jul 31 17:07:16 -0700 2009 |
README
= jruby-quartz
== Instructions
Requires the following jars in your application container and if running with just jruby place these in your
$JRUBY_HOME/lib
commons-collections-3.2.x.jar
commons-logging.jar
log4j.jar
quartz-1.6.x.jar
If you are running a current version of JBoss you already have these!
If you are running an alternative container you will need to check it's lib
directory for the presence of these jars.
If you need these jars you can find them within the apache commons project and
the quartz jar on opensymphony
== Installation
gem install git://github.com/techwhizbang/jruby-quartz.git
== Usage
The best way to leverage jruby-quartz is to simply extend the BaseScheduler and
implement any number of jobs you need to run.
For example all you need to do is specify some basic attributes including the
cron expression representing the frequency of the job(s) you want to with it:
class IntegrationScheduler < BaseScheduler
def initialize(cron_expression)
super
@cron_expression = cron_expression
@base_jobs_group = "IntegrationJobs"
@base_triggers_group = "IntegrationTriggers"
end
end
Then just extend the base job by putting all of the work you want to perform inside the
perform_job method.
class IntegrationJob < Jobs::BaseJob
def perform_job
worker_one = mock('worker class one', :whatever => "123")
worker_two = mock('worker class two', :whatever => '123')
end
end
If you are running Rails you can throw the schedule! method into a custom initializer.
An example of this would be like so:
Notice the Rails.env /container/, I defined custom environments that only run when
inside a Java container so that the schedule! method doesn't get fired off during
testing.
if RUBY_PLATFORM =~ /java/
LoggerOneScheduler.new("0 0/1 * * * ?").schedule!(Jobs::LoggerOneJob)
LoggerTwoScheduler.new("0 0/2 * * * ?").schedule!(Jobs::LoggerTwoJob)
end
If you are planning on using this with a Rails stack, I would recommend using this
only with Rails 2.2 or higher because thread safety == 1 runtime
1 runtime means your schedule initializer is only called once.
=== Other
Problems, comments, and suggestions all welcome. techwhizbang@gmail.com or visit my blog
http://techwhizbang.com

