On Fri, Jan 14, 2011 at 09:39:43AM +0900, John Mettraux wrote:
>
> On Thu, Jan 13, 2011 at 07:20:15PM +0100, Gonzalo Suárez wrote:
> >
> > I would like to give the storage_participant some notification
> > behavior (with xmpp).
> >
> > (...)
> >
> > Then I thought that I could modify the original storage_participant to
> > receive a flag (:xmpp => true). If a participant is registered as
> > storage_participant with xmpp flag then after consume(), reply(),
> > cancel()... methods, some xmpp task would be fired up?
Hello Gonzalo,
sorry, I forget the reply() one :
---8<---
require 'rubygems'
require 'ruote'
engine = Ruote::Engine.new(Ruote::Worker.new(Ruote::HashStorage.new))
class GonzaloParticipant < Ruote::StorageParticipant
def consume(workitem)
puts "XMPP: consuming wi for #{workitem.fei.sid}" if @options['xmpp']
super
end
def cancel(fei, flavour)
puts "XMPP: cancelling wi at #{fei.sid}" if @options['xmpp']
super
end
def on_reply(workitem)
puts "XMPP: workitem is back for #{workitem.fei.sid}" if @options['xmpp']
end
end
engine.register do
form GonzaloParticipant, :xmpp => true
#bob GonzaloParticipant
end
# or
#engine.participant_list = [
# [ 'form', 'GonzaloParticipant', { 'xmpp' => 'true' } ]
#]
# note that symbols are turned into strings when stored,
# it's a JSON world
pdef = Ruote.process_definition do
form
end
engine.noisy = true
# displaying the worker's work, step by step, in yellow
wfid = engine.launch(pdef)
engine.wait_for(:form)
engine.storage_participant.reply(engine.storage_participant.first)
engine.wait_for(wfid)
--->8---
Gist is at :
https://gist.github.com/779143
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