On Fri, Feb 12, 2010 at 7:14 PM, Silvester <[email protected]> wrote:
> Sorry for the late response... Thanks for your comments.
>
> I am in a firm which is a subsidiary of Pershing LLC.

Hello,

ah cool, I never knew this company was using OpenWFE.


> Similarly, can i forward the workitem from one participant to another
> in the below ruby code?
>
> *********RUBY**********
>
> $:.unshift('lib') # running from ruote/ probably
>
> require 'rubygems'
> require 'ruote'
> require 'ruote/storage/fs_storage'
>
> storage = Ruote::FsStorage.new('ruote_work')
>
> engine = Ruote::Engine.new(
>   Ruote::Worker.new(storage))
>
> # 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)
>
> ***********************

This ruby code is automatically forwarding from alpha to bravo. Those
block participants are executing their ruby code and immediately
replying to the engine.

Here is your Java example translated to Ruby (original at
http://gist.github.com/302474 )

---8<---
require 'rubygems'
require 'ruote'
require 'ruote/storage/fs_storage'

engine =
  Ruote::Engine.new(
    Ruote::Worker.new(
      Ruote::FsStorage.new('ruote_work')))

# registering participants

engine.register_participant :alpha, Ruote::StorageParticipant
engine.register_participant :bravo, Ruote::StorageParticipant

part = Ruote::StorageParticipant.new(engine)
  # a bit tricky : part is used to query the storage participant

# defining a process

pdef = Ruote.process_definition :name => 'test' do
  sequence do
    alpha
    bravo
  end
end

wfid = engine.launch(pdef)

puts '-' * 80
puts "launched process #{wfid}"

engine.wait_for(:alpha)

puts '-' * 80
%w[ alpha bravo ].each do |pname|
  puts "participant #{pname} has #{part.by_participant(pname).size} workitems"
end

wi = part.by_participant('alpha').first

puts '-' * 80
puts "forwarding workitem #{wi.fei.to_storage_id}"

part.reply(wi)

engine.wait_for(:bravo)

puts '-' * 80
%w[ alpha bravo ].each do |pname|
  puts "participant #{pname} has #{part.by_participant(pname).size} workitems"
end

puts '-' * 80
puts "bravo got a workitem :
#{part.by_participant('bravo').first.fei.to_storage_id}"
--->8---

One difference with your java example is that the workitems are stored
on file (and the engine is storing on file as well).


Best regards,

-- 
John Mettraux   -   http://jmettraux.wordpress.com

-- 
you received this message because you are subscribed to the "ruote users" group.
to post : send email to [email protected]
to unsubscribe : send email to [email protected]
more options : http://groups.google.com/group/openwferu-users?hl=en

Reply via email to