A spike to test out various task execution outcomes.
Do the ping.
# File lib/symphony/tasks/simulator.rb, line 34
def work( payload, metadata )
if metadata[:properties][:headers] &&
metadata[:properties][:headers]['x-death']
puts "Deaths! %p" % [ metadata[:properties][:headers]['x-death'] ]
end
sleep rand( 0.0 .. 2.0 )
val = Random.rand
case
when val < 0.05
$stderr.puts "Simulating an error in the task (reject)."
raise "OOOOOPS!"
when val < 0.10
$stderr.puts "Simulating a soft failure in the task (reject+requeue)."
return false
when val < 0.15
$stderr.puts "Simulating a timeout case"
sleep( self.class.timeout + 1 ) if self.class.timeout
else
$stderr.puts "Simulating a successful task run (accept)"
puts( payload.inspect )
return true
end
true
end