On Sun, May 09, 2010 at 01:07:33AM -0700, Kandada Boggu wrote:
>
> Is there a way to make the block participant stateless?
>
> - The block participant code does not refer to variable defined
> outside the block.
> - Same block participant is loaded by all workers and the engine.
>
> Sample participant:
> engine.register_participant('trace') do |workitem|
> puts workitem.fields['foo']
> end
>
> PS: I am using RuoteKit on rails.
> PPS: Ruote documentation states that block participants are stateful.
> I am trying to understand if this restriction applies under the
> circumstances explained above.
Hello,
yes, it is possible, simply wrap the block in a class :
---8<---
class MyTraceParticipant
include Ruote::LocalParticipant
def consume (workitem)
puts workitem.fields['foo']
reply_to_engine(workitem)
end
end
--->8---
Note the explicit reply_to_engine call.
Make then sure all the workers have access to the code of this class.
Then
---8<---
RuoteKit.engine.register_participant('trace', MyTraceParticipant)
# or, RuoteKit style, in config/initializers/ruote.rb :
RuoteKit.configure do |c|
# ...
c.register do
participant('trace', MyTraceParticipant)
# ...
end
end
--->8---
Please read this answer for a suggestion of where to place such participants in
the Rails file hierarchy :
http://groups.google.com/group/openwferu-users/msg/f3029ef07c2825cd
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