Created
September 24, 2010 09:41
-
-
Save anonymous/595132 to your computer and use it in GitHub Desktop.
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
| $:.unshift('lib') # running from ruote/ probably | |
| require 'fileutils' | |
| require 'rubygems' | |
| require 'ruote' | |
| require 'ruote/storage/fs_storage' | |
| # preparing the engine | |
| engine = Ruote::Engine.new( | |
| Ruote::Worker.new( | |
| Ruote::FsStorage.new( | |
| 'ruote_work', | |
| 's_logger' => [ 'ruote/log/test_logger', 'Ruote::TestLogger' ]))) | |
| # registering participants | |
| engine.register_participant :alpha do |workitem| | |
| workitem.fields['message'] = { 'text' => 'hello !', 'author' => 'Alice' } | |
| end | |
| engine.register_participant :bravo do |workitem| | |
| puts "I received a message from #{workitem.fields['message']['author']}" | |
| end | |
| # defining a process | |
| pdef = Ruote.process_definition :name => 'test' do | |
| sequence do | |
| participant :alpha | |
| wait '5s' | |
| participant :bravo | |
| end | |
| end | |
| # launching, creating a process instance | |
| WFID_FILE = 'ruote_quickstart_wfid.txt' | |
| wfid = File.read(WFID_FILE).strip rescue nil | |
| wfid ||= engine.launch(pdef) | |
| File.open(WFID_FILE, 'wb') { |f| f.write(wfid) } | |
| engine.wait_for(wfid) | |
| # blocks current thread until our process instance terminates | |
| FileUtils.rm(WFID_FILE) | |
| # => 'I received a message from Alice' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment