Created
March 22, 2012 15:57
-
-
Save netinlet/2159172 to your computer and use it in GitHub Desktop.
Ruote Concurrence
This file contains hidden or 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' | |
begin | |
require 'yajl' | |
rescue LoadError => le | |
require 'json' | |
end | |
require 'ruote' | |
require 'ruote/storage/fs_storage' | |
dashboard = Ruote::Dashboard.new( | |
Ruote::Worker.new( | |
Ruote::FsStorage.new('ruote_work'))) | |
dashboard.register_participant :con1 do |workitem| | |
puts "in con1" | |
workitem.fields["msg1"] = "msg1 - workitem" | |
end | |
dashboard.register_participant :con2 do |workitem| | |
puts "in con2" | |
workitem.fields["msg2"] = "msg2 - workitem" | |
end | |
dashboard.register_participant( 'print_messages' ) do |workitem| | |
puts workitem.lookup('msg1') if workitem.lookup("msg1") | |
puts workitem.lookup('msg2') if workitem.lookup("msg2") | |
end | |
PDEF = Ruote.process_definition :name => 'test parallel' do | |
concurrence do | |
con1 | |
con2 | |
end | |
print_messages | |
end | |
wfid = dashboard.launch(PDEF) | |
dashboard.wait_for(wfid) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment