On Tue, Apr 20, 2010 at 04:29:47AM -0700, Olle wrote:
>
> > > 1. Don't know how to pass desired wait interval to "wait" from
> > > "participant". May be process variables could be utilized for this
> > > goal?
> > > 2. Don'k know how to get information about intercepted exception in
> > > the error handler subprocess\participant. Is it possible?
> >
> > It was not really possible, but I have added that for you (for all the
> > ruote users) :
> >
> > http://github.com/jmettraux/ruote/commit/00588816dc8d0221e1f1f7ca5820...
> >
>
> John, thank you! This potentially solves my request.
> I've build a quick test (http://gist.github.com/372307):
> ---
> pdef = Ruote.process_definition :name => 'test' do
>
> sequence do
> external_work :tag => 'tag1', :on_error => 'handle_error'
> echo 'exiting...'
> end
>
> define 'handle_error' do
> trace
> echo 'sleeping for ${f:sleep_for}..'
> wait "${f:sleep_for}"
> echo 'redoing...'
> _redo :ref => 'tag1'
> end
>
> end
> --
> This process should re-apply desired expression after a sleeping. But
> it didn't. Here is my output:
>
> What could be wrong here?
Hello Oleg,
it can't redo since the tag 'tag1' no longer exists when the error gets handled.
Placing the :tag => 'tag1' on the sequence should do it.
.
But perhaps this is cleaner (and 'handle' is re-usable) :
---8<---
pdef = Ruote.process_definition do
sequence do
handle { external_work }
end
define 'handle' do
repeat do
apply :on_error => 'undo'
_break :unless => '${f:time_to_retry}'
sleep '${f:time_to_retry}'
end
end
end
--->8---
:on_error => 'undo' vaporizes the error and lets the flow continue, this
example assumes you've set the field 'time_to_retry' right before raising in
the external_work participant (since it's now OK).
Note : apply is a bit like a ruby 'yield'.
.
Another alternative that we discussed : placing all the retry logic inside of
the participant and hide it from the 'business process'. Still worth a try.
Maybe I could provide you with a way for the local participant to re_apply
itself after a while :
---8<---
class OlegParticipant
include Ruote::LocalParticipant
def consume (workitem)
# ...
if something_went_wrong
re_apply(workitem, :in => '3m')
else
reply_to_engine(workitem)
end
end
def cancel (flavour)
# have to unschedule the queued re_applies if any...
end
end
--->8---
Let me think about it...
I will look at the on_reply very soon.
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