Skip to content

Instantly share code, notes, and snippets.

@tobias
Forked from abstractj/long_running_job.rb
Created January 16, 2012 16:34
Show Gist options
  • Save tobias/1621669 to your computer and use it in GitHub Desktop.
Save tobias/1621669 to your computer and use it in GitHub Desktop.
integration_test
# in the test:
queue = TorqueBox::Messaging::Queue.new( '/queue/response' )
queue.receive( :timeout => 120_000 ).should == 'started'
queue.receive( :timeout => 5_000 ).should be_nil
class LongRunningJob
include TorqueBox::Injectors
def initialize(opts)
@options = opts
@response_queue = inject( '/queue/response' )
end
def run()
$stderr.puts "Job executing! queue is #{@response_queue}"
@response_queue.publish( 'started' )
sleep( 5 )
@response_queue.publish( 'done' )
end
end
jobs:
job.four:
job: LongRunningJob
description: My long running job has timeout
cron: "*/1 * * * * ?"
timeout: 3 s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment