| Module | Ruote::LocalParticipant |
| In: |
lib/ruote/part/local_participant.rb
|
Provides methods for ‘local’ participants.
Assumes the class that includes this module has a context method that points to the worker or engine ruote context.
It‘s "local" because it has access to the ruote storage.
| context | [RW] | the reply_to_engine method is there |
Use this method to re_dispatch the workitem.
It takes two options :in and :at for "later re_dispatch".
Look at the unschedule_re_dispatch method for an example of participant implementation that uses re_dispatch.
Without one of those options, the method is a "reject".
Cancels the scheduled re_dispatch, if any.
An example or ‘retrying participant’ :
class RetryParticipant
include Ruote::LocalParticipant
def initialize (opts)
@opts = opts
end
def consume (workitem)
begin
do_the_job
reply(workitem)
rescue
re_dispatch(workitem, :in => @opts['delay'] || '1s')
end
end
def cancel (fei, flavour)
unschedule_re_dispatch(fei)
end
end
Note how unschedule_re_dispatch is used in the cancel method. Warning, this example could loop forever…