You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Dario D <da...@gmail.com> on 2011/09/12 11:17:25 UTC

[scxml] Handling condition errors in transitions

Hello,

I have an SCXML workflow as given below. The conditions in the transitions
of "state2" are invalid because they have an invalid variable name
"trans-0". The application was made in the way that on each step forward, it
triggers an "action.next" event, followed by any external events inserted by
a custom ErrorReporter. This way, the workflow would move to the "_error"
state on every error. The problem is that on parsing of "state2" transition
conditions, it did not move to "_error" state. The following sequence
ocurred:

1) Workflow follows to "state2"
2) Current state is "state2", application triggers an "action.next" event
3) ErrorReported inserted two "action.error" events in the queue
4) However, the workflow is already in "_end" state (why?)
5) Application reads the external events queue, triggers two "action.error"
events, but nothing happens because workflow is in "_end" state

Why workflow ends up in "_end" state after parsing error?

*<scxml xmlns="**http://www.w3.org/2005/07/scxml*<http://www.w3.org/2005/07/scxml>
*"
       version="1.0"
       initialstate="_start">*
*    <state id="_start">
        <transition target="_processing" />
    </state>*
*    <state id="_processing">*
*        <initial>
            <transition target="_actions"/>
        </initial>*
*        <history id="_history" type="deep">*
*        </history>

        <state id="_actions" initial="state1">
            <state id="state1">
                <transition event="action.next" target="state2" />
            </state>*
*            <state id="state2">
                <transition event="action.next"
cond="trans-0.parameter.P_InitialBalance == 7" target="state3" />
                <transition event="action.next"
cond="trans-0.parameter.P_InitialBalance == 0" target="state4" />
            </state>*
*            <state id="state3">
                <transition event="action.next" target="state5" />
            </state>*
*            <state id="state4">
                <transition event="action.next" target="state5" />
            </state>*
*            <state id="state5">
            </state>
        </state>*
*        <transition event="action.next" target="_end" />*
*        <transition event="action.end" target="_end"/>*
*        <transition event="error.*" target="_error" />*
*    </state>*
*    <state id="_error">*
*        <onentry>
            <log expr="'In error'"/>
        </onentry>*
*        <transition event="action.next" target="_history"/>*
*        <transition event="action.end" target="_end"/>*
*    </state>*
*    <state id="_end" final="true">*
*    </state>*
*</scxml>*

Re: [scxml] Handling condition errors in transitions

Posted by Rahul Akolkar <ra...@gmail.com>.
On Tue, Sep 13, 2011 at 1:43 PM, Dario D <da...@gmail.com> wrote:
> 2011/9/13 Rahul Akolkar rahul.akolkar@gmail.com
>
>>
>> When the state machine is in "state2", there are three candidate
>> transitions that match event "action.next" -- two with guards in
>> "state2" and one unguarded or condition-less in state "_processing".
>> The two in "state2" are not followed, but subsequently the unguarded
>> one is selected and followed which leads to state "_end". Given state
>> "_end" is a final state, no further events triggered on the state
>> machine will have any effect.
>>
>>
>
> Thank you Rahul. There is no way to "catch" the parsing error if it happens
> in such conditions, and consequently trigger an error event?
<snip/>

If thats what is desired, the state machine can be changed to reflect
that. There isn't any inherent limitation precluding those kinds of
patterns. There are a number of ways in which the state machine can be
changed here, such as:

 * Fix the root cause that causes ill-formed expressions to appear
 * Transition to a non-final state that can still process "error.*" events
 * Use better ontology for events, rather than one "action.next" that
is shared at different "path fragment depths"

-Rahul

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [scxml] Handling condition errors in transitions

Posted by Dario D <da...@gmail.com>.
2011/9/13 Rahul Akolkar rahul.akolkar@gmail.com

>
> When the state machine is in "state2", there are three candidate
> transitions that match event "action.next" -- two with guards in
> "state2" and one unguarded or condition-less in state "_processing".
> The two in "state2" are not followed, but subsequently the unguarded
> one is selected and followed which leads to state "_end". Given state
> "_end" is a final state, no further events triggered on the state
> machine will have any effect.
>
> -Rahul
>

Thank you Rahul. There is no way to "catch" the parsing error if it happens
in such conditions, and consequently trigger an error event?

Re: [scxml] Handling condition errors in transitions

Posted by Rahul Akolkar <ra...@gmail.com>.
On Mon, Sep 12, 2011 at 5:17 AM, Dario D <da...@gmail.com> wrote:
> Hello,
>
> I have an SCXML workflow as given below. The conditions in the transitions
> of "state2" are invalid because they have an invalid variable name
> "trans-0". The application was made in the way that on each step forward, it
> triggers an "action.next" event, followed by any external events inserted by
> a custom ErrorReporter. This way, the workflow would move to the "_error"
> state on every error. The problem is that on parsing of "state2" transition
> conditions, it did not move to "_error" state. The following sequence
> ocurred:
>
> 1) Workflow follows to "state2"
> 2) Current state is "state2", application triggers an "action.next" event
> 3) ErrorReported inserted two "action.error" events in the queue
> 4) However, the workflow is already in "_end" state (why?)
> 5) Application reads the external events queue, triggers two "action.error"
> events, but nothing happens because workflow is in "_end" state
>
> Why workflow ends up in "_end" state after parsing error?
>
<snip/>

When the state machine is in "state2", there are three candidate
transitions that match event "action.next" -- two with guards in
"state2" and one unguarded or condition-less in state "_processing".
The two in "state2" are not followed, but subsequently the unguarded
one is selected and followed which leads to state "_end". Given state
"_end" is a final state, no further events triggered on the state
machine will have any effect.

-Rahul


> *<scxml xmlns="**http://www.w3.org/2005/07/scxml*<http://www.w3.org/2005/07/scxml>
> *"
>       version="1.0"
>       initialstate="_start">*
> *    <state id="_start">
>        <transition target="_processing" />
>    </state>*
> *    <state id="_processing">*
> *        <initial>
>            <transition target="_actions"/>
>        </initial>*
> *        <history id="_history" type="deep">*
> *        </history>
>
>        <state id="_actions" initial="state1">
>            <state id="state1">
>                <transition event="action.next" target="state2" />
>            </state>*
> *            <state id="state2">
>                <transition event="action.next"
> cond="trans-0.parameter.P_InitialBalance == 7" target="state3" />
>                <transition event="action.next"
> cond="trans-0.parameter.P_InitialBalance == 0" target="state4" />
>            </state>*
> *            <state id="state3">
>                <transition event="action.next" target="state5" />
>            </state>*
> *            <state id="state4">
>                <transition event="action.next" target="state5" />
>            </state>*
> *            <state id="state5">
>            </state>
>        </state>*
> *        <transition event="action.next" target="_end" />*
> *        <transition event="action.end" target="_end"/>*
> *        <transition event="error.*" target="_error" />*
> *    </state>*
> *    <state id="_error">*
> *        <onentry>
>            <log expr="'In error'"/>
>        </onentry>*
> *        <transition event="action.next" target="_history"/>*
> *        <transition event="action.end" target="_end"/>*
> *    </state>*
> *    <state id="_end" final="true">*
> *    </state>*
> *</scxml>*
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org