On Sat, Oct 3, 2009 at 5:12 AM, David <[email protected]> wrote:
>
> My question is, how can I best code either the process definition or
> the participants (the latter is to be preferred, I think), to do the
> following:
>
> 1.  We should be able to retry the concurrence containing "c" a few
> times.  Note that it is probably bad just to retry "c", because when
> "c" failed the process probably allowed either "yah" or "hohum" to
> "win" the concurrence.
>
> 2,  If "c" fails on the third attempt, we should roll back the entire
> process.  That means not just cancelling it, but also invoking some
> clean-up partipants that undo the effects of "b" and "a."

Hello David,

please have a look at on_error/on_cancel [1], this piece of doc was
written for ruote 0.9.20+ but it's valid for ruote 2.0 as well (have
to port it as well). The idea is that you can indicate in the process
definition which participant or subprocess should handle an error for
a segment of process instance. :on_cancel is here for "cleaning up"
when a process segment gets cancelled.

Any expression accepts the :on_error/:on_cancel attributes, but most
of the time it's more productive to place them on sequences, cursors
or concurrences and the like.

Apart from that, participant implementations have a consume and a
cancel method. The cancel method is called when the participant is
'active' (waiting the answer of the real participant). Since
BlockParticipant are usually meant to reply very quickly, their cancel
implementation is empty [2], that can get overriden, but then it's
probably better to write one's own participant implementation instead
of stretching BlockParticipant.

I don't know what should stand behind participant c, but you could
integrate the retry/fail logic into it. Upon one consume() call, 3
tries would be attempted and if the third fails the participant can
cancel the whole process by calling engine.cancel_process(wfid). The
clean up participants/subprocesses can be specified via an :on_cancel
placed at the root of the process definition.

Note that calling engine.kill_process(wfid) prevents any :on_cancel
from being called.


[1] http://openwferu.rubyforge.org/on_error.html
[2] 
http://github.com/jmettraux/ruote/blob/ruote2.0/lib/ruote/part/block_participant.rb#L92-95


I hope this will help, 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