-
-
Save anonymous/485559 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'yajl' | |
require 'ruote' | |
engine = Ruote::Engine.new(Ruote::Worker.new(Ruote::HashStorage.new)) | |
pdef = Ruote.define do | |
sequence do | |
alpha | |
bravo | |
zebulon | |
end | |
end | |
class ThisParticipant | |
include Ruote::LocalParticipant | |
def consume (workitem) | |
puts "* #{workitem.participant_name}" | |
reply_to_engine(workitem) | |
end | |
end | |
class ThatParticipant | |
include Ruote::LocalParticipant | |
def consume (workitem) | |
puts ". #{workitem.participant_name}" | |
# no reply to engine | |
end | |
def cancel (fei, flavour) | |
# ok, let pass | |
end | |
def do_not_thread; true; end | |
end | |
engine.register_participant 'alpha', ThisParticipant | |
engine.register_participant 'bravo', ThisParticipant | |
engine.register_participant 'charlie', ThisParticipant | |
engine.register_participant 'zebulon', ThatParticipant | |
#engine.context.logger.noisy = true | |
wfid = engine.launch(pdef) | |
engine.wait_for(:zebulon) | |
ps = engine.process(wfid) | |
sequence = ps.expressions.find { |fexp| fexp.fei.expid == '0_0' } | |
puts "re_applying..." | |
engine.re_apply(sequence.fei, :tree => Ruote.to_tree do | |
sequence do | |
charlie | |
bravo | |
alpha | |
end | |
end) | |
engine.wait_for(wfid) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment