make sure you are using Ruby 1.8.5 at least
$ sudo gem install -y rufus-mnemo openwferu
edit a file named ‘openwferu.rb‘
require 'rubygems'
require 'openwfe/def'
require 'openwfe/workitem'
require 'openwfe/engine/engine'
#
# instantiating an engine
engine = OpenWFE::Engine.new
#
# adding some participants
engine.register_participant :alice do |workitem|
puts "alice got a workitem..."
workitem.alice_comment = "this thing looks interesting"
end
engine.register_participant :bob do |workitem|
puts "bob got a workitem..."
workitem.bob_comment = "not for me, I prefer VB"
workitem.bob_comment2 = "Bob rules"
end
engine.register_participant :summarize do |workitem|
puts
puts "summary of process #{workitem.fei.workflow_instance_id}"
workitem.attributes.each do |k, v|
next unless k.match ".*_comment$"
puts " - #{k} : '#{v}'"
end
end
#
# a process definition
class TheProcessDefinition0 < OpenWFE::ProcessDefinition
sequence do
concurrence do
participant :alice
participant :bob
end
participant :summarize
end
end
#
# launching the process
li = OpenWFE::LaunchItem.new(TheProcessDefinition0)
li.initial_comment = "please give your impressions about http://ruby-lang.org"
fei = engine.launch li
#
# 'fei' means FlowExpressionId, the fei returned here is the
# identifier for the root expression of the newly launched process
puts "started process '#{fei.workflow_instance_id}'"
engine.wait_for fei
#
# blocks until the process terminates
run that file
$ ruby openwferu.rb
there should be an output like that one :
alice got a workitem...
bob got a workitem...
summary of process 1173232330251
- bob_comment : 'not for me, I prefer VB'
- alice_comment : 'this thing looks interesting'
- initial_comment : 'please give your impressions about http://ruby-lang.org'
There are two key concepts in OpenWFEru : business processes and participants.
Business processes are defined via trees of expressions named process definitions. Learn more about each of the expressions.
OpenWFEru comes with a growing set of predefined participants.
To set up a standalone or an embedded OpenWFEru engine, you can take inspiration in the engine template.
Feel free to ask them on the users mailing list.
Maybe OpenWFEru isn’t for you :
$ sudo gem uninstall openwferu
(the openwferu gem depends on the gems ‘rufus-lru’, ‘rufus-scheduler’, ‘rufus-eval’ and ‘rufus-dollar’. You might want to remove them as well)