Skip to content

Instantly share code, notes, and snippets.

Created March 14, 2013 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5165918 to your computer and use it in GitHub Desktop.
Save anonymous/5165918 to your computer and use it in GitHub Desktop.
showcasing ruote error handling participants
# Gemfile
#
# ---8<---
# source :rubygems
#
# gem 'yajl-ruby', :require => 'yajl'
# #gem 'ruote'
# gem 'ruote', :git => 'git://github.com/jmettraux/ruote.git'
# --->8---
require 'pp'
require 'ruote'
ruote =
Ruote::Dashboard.new(
Ruote::Worker.new(
Ruote::HashStorage.new))
ruote.noisy = (ENV['NOISY'] == 'true')
#
# define participant classes (if needed)
#
class MyParticipant < Ruote::Participant
def on_workitem
puts "#{self.class} saw workitem for #{workitem.participant_name}"
raise 'arghhhhhhhhhhh!'
#reply
end
end
class MyErrorHandlerParticipant < Ruote::Participant
def on_workitem
puts
puts '=' * 80
puts 'error:'
pp workitem.error
puts '=' * 80
rescue => ex
puts '*' * 80
p ex
puts '*' * 80
end
end
#
# register participants
#
ruote.register do
participant 'alpha', MyParticipant
participant 'errory', MyErrorHandlerParticipant
end
#
# define process
#
pdef =
Ruote.define do
sequence :on_error => 'errory' do
alpha
end
end
#
# run process
#
wfid = ruote.launch(pdef)
sleep 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment