Sha256: 529e185e574d29ae0a7ac794c6259fe414a14ae18943a5160f5e2a6bc35f114b

Contents?: true

Size: 895 Bytes

Versions: 4

Compression:

Stored size: 895 Bytes

Contents

$:.unshift('lib') # running from ruote/ probably

require 'rubygems'
require 'ruote'
require 'ruote/storage/fs_storage'

# preparing the engine

engine = Ruote::Engine.new(
  Ruote::Worker.new(
    Ruote::FsStorage.new("ruote_work")))
    #Ruote::HashStorage.new))

# 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
    participant :bravo
  end
end

# launching, creating a process instance

wfid = engine.launch(pdef)

engine.wait_for(wfid)
  # blocks current thread until our process instance terminates

# => 'I received a message from Alice'

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruote-2.1.4 examples/ruote_quickstart.rb
ruote-2.1.3 examples/ruote_quickstart.rb
ruote-2.1.2 examples/ruote_quickstart.rb
ruote-2.1.1 examples/ruote_quickstart.rb