You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Roger Hoover <ro...@gmail.com> on 2008/11/07 04:38:00 UTC

[SCXML] Possible bug passing _eventdatamap across parallel contexts when event has delay

Hi,

I'm new to Commons SCXML but I ran into what looks like a bug to me.  When
an event generated in one context gets sent to a sibling context with a
delay, the _eventdata object is null.  Oddly enough, when delay unset or set
to 0ms, it works fine.  I created a test file based on eventdata-03.xml to
expose it.   Set delay="0ms" and the counter state machine makes it to the
thirty state.  Set delay="1ms" and it doesn't.

Any help is appreciated.  Thanks,

Roger


<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
-->
<scxml xmlns="http://www.w3.org/2005/07/scxml"
      version="1.0"
      initialstate="start">

    <parallel id="start">

        <state id="simulatedUser">
            <datamodel>
                <data name="one" expr="1" />
                <data name="two" expr="2" />
            </datamodel>

            <onentry>
                <send event="event.bar" namelist="one two" delay="1ms"/>
            </onentry>
            <transition event="event.bar">
                <log label="'simulatedUser'"
expr="_eventdatamap['event.bar'].one + ', ' +
_eventdatamap['event.bar'].two"/>
            </transition>
        </state>

        <state id="counter">
            <initial>
                <transition target="twenty"/>
            </initial>

            <state id="twenty">
                <transition event="event.bar"
                    cond="_eventdatamap['event.bar'].one +
_eventdatamap['event.bar'].two eq 3"
                    target="thirty"/>
                <transition event="event.bar">
                    <log label="'event.bar in twenty state'"
expr="_eventdatamap['event.bar'].one + ', ' +
_eventdatamap['event.bar'].two"/>
                </transition>
            </state>

            <state id="thirty" final="true"/>
        </state>

    </parallel>

</scxml>

Re: [SCXML] Possible bug passing _eventdatamap across parallel contexts when event has delay

Posted by Rahul Akolkar <ra...@gmail.com>.
On Fri, Nov 7, 2008 at 6:47 PM, Roger Hoover <ro...@gmail.com> wrote:
> Rahul,
>
> Thanks for the quick response.  More questions/comments inline.
>
<snip/>
>
> Does Commons SCXML support the 'basichttp' targettype?  If not, is there an
> open source EventDispatcher for basichttp already out there that you know
> of?
>
<snap/>

No, because IMO the spec needs some more clarity about the 'basichttp'
targettype. Once that happens, it would make sense to add it to
Commons SCXML. Not sure if there is any such implementation out there.


>
>>
>> The behavior you mention above does seem like a bug. Obviously, events
>> with or without delay are handled differently (the former are
>> scheduled for execution). I suspect the SimpleScheduler implementation
>> may be overlooking event payloads, or not processing them correctly.
>> Please file a bug report in JIRA [2] and attach your test case, and
>> I'll take a look at this.
>
>
> Thanks.  I filed a JIRA here. https://issues.apache.org/jira/browse/SCXML-87
>
<snip/>

Great, I'll try to take a look within a couple of days.

-Rahul

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


Re: [SCXML] Possible bug passing _eventdatamap across parallel contexts when event has delay

Posted by Rahul Akolkar <ra...@gmail.com>.
On Sun, Nov 9, 2008 at 10:22 AM, Ingmar Kliche
<in...@googlemail.com> wrote:
> Hi Roger,
>
> as far as I am aware commons-scxml does not support basichttp. But it is
> relatively easy to implement e.g. using Jakarta commons httpClient (
> http://hc.apache.org/httpclient-3.x).
>
<snip/>

Yup, on both counts :-) If you already have one implemented, and are
so inclined, feel free to contribute a patch to JIRA.


> I think the interesting peace is how to feed back the result of the HTTP
> request into the engine. The dispatcher is independent of the data model
> implementation (i.e. the context). By that I mean the dispatcher don't know
> about the context implementation. Different contexts (may) require to
> represent data differently. For example if the HTTP server returns an XML
> string, how is this string fed into the engine in a generic way (i.e. that
> it works with different contexts)? The JEXL context may require (the
> dispatcher!) to parse the XML string into a Java DOM object and fire it as
> payload of an event into the engine. Whereas another context (which may not
> be capable of XPath) may require (the dispatcher!) to convert the XML string
> into some JSON representation and feed it to the context.
>
> That means the dispatcher needs to convert the data (received from an
> external HTTP server) into an object which is appropriate for the context in
> use. This is somehow dirty.
>
<snap/>

If anything seems dirty or unclear (as I just said, I agree it needs
more clarity) then the WG needs to be tasked with adding the necessary
details to the working draft. I will try to remember to bring this up
there.

-Rahul


> - Ingmar.
>
<snip/>

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


Re: [SCXML] Possible bug passing _eventdatamap across parallel contexts when event has delay

Posted by Ingmar Kliche <in...@googlemail.com>.
Hi Roger,

as far as I am aware commons-scxml does not support basichttp. But it is
relatively easy to implement e.g. using Jakarta commons httpClient (
http://hc.apache.org/httpclient-3.x).

I think the interesting peace is how to feed back the result of the HTTP
request into the engine. The dispatcher is independent of the data model
implementation (i.e. the context). By that I mean the dispatcher don't know
about the context implementation. Different contexts (may) require to
represent data differently. For example if the HTTP server returns an XML
string, how is this string fed into the engine in a generic way (i.e. that
it works with different contexts)? The JEXL context may require (the
dispatcher!) to parse the XML string into a Java DOM object and fire it as
payload of an event into the engine. Whereas another context (which may not
be capable of XPath) may require (the dispatcher!) to convert the XML string
into some JSON representation and feed it to the context.

That means the dispatcher needs to convert the data (received from an
external HTTP server) into an object which is appropriate for the context in
use. This is somehow dirty.

- Ingmar.


2008/11/8 Roger Hoover <ro...@gmail.com>

> Rahul,
>
> Thanks for the quick response.  More questions/comments inline.
>
> On Fri, Nov 7, 2008 at 11:54 AM, Rahul Akolkar <rahul.akolkar@gmail.com
> >wrote:
>
> > On Thu, Nov 6, 2008 at 10:38 PM, Roger Hoover <ro...@gmail.com>
> > wrote:
> > > Hi,
> > >
> > > I'm new to Commons SCXML but I ran into what looks like a bug to me.
> >  When
> > > an event generated in one context gets sent to a sibling context with a
> > > delay, the _eventdata object is null.  Oddly enough, when delay unset
> or
> > set
> > > to 0ms, it works fine.  I created a test file based on eventdata-03.xml
> > to
> > > expose it.   Set delay="0ms" and the counter state machine makes it to
> > the
> > > thirty state.  Set delay="1ms" and it doesn't.
> > >
> > <snip/>
> >
> > A slight digression, but might be relevant background -- the
> > EventDispatcher [1] (which handles <send> and <cancel>) is anticipated
> > to be user-authored for any usages of the library of reasonable
> > complexity. We do provide simple examples (see implementing classes in
> > Javadoc) as a way to get folks started, but these do not handle any
> > targettypes beyond 'scxml' (which is also the default).
> >
>
> Does Commons SCXML support the 'basichttp' targettype?  If not, is there an
> open source EventDispatcher for basichttp already out there that you know
> of?
>
>
> >
> > The behavior you mention above does seem like a bug. Obviously, events
> > with or without delay are handled differently (the former are
> > scheduled for execution). I suspect the SimpleScheduler implementation
> > may be overlooking event payloads, or not processing them correctly.
> > Please file a bug report in JIRA [2] and attach your test case, and
> > I'll take a look at this.
>
>
> Thanks.  I filed a JIRA here.
> https://issues.apache.org/jira/browse/SCXML-87
>
> >
> >
> > -Rahul
> >
> > [1]
> >
> http://commons.apache.org/scxml/0.8/apidocs/org/apache/commons/scxml/EventDispatcher.html
> > [2] http://commons.apache.org/scxml/issue-tracking.html
> >
> >
> > > Any help is appreciated.  Thanks,
> > >
> > > Roger
> > >
> > >
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <!--
> > >  * Licensed to the Apache Software Foundation (ASF) under one or more
> > >  * contributor license agreements.  See the NOTICE file distributed
> with
> > >  * this work for additional information regarding copyright ownership.
> > >  * The ASF licenses this file to You under the Apache License, Version
> > 2.0
> > >  * (the "License"); you may not use this file except in compliance with
> > >  * the License.  You may obtain a copy of the License at
> > >  *
> > >  *     http://www.apache.org/licenses/LICENSE-2.0
> > >  *
> > >  * Unless required by applicable law or agreed to in writing, software
> > >  * distributed under the License is distributed on an "AS IS" BASIS,
> > >  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> > implied.
> > >  * See the License for the specific language governing permissions and
> > >  * limitations under the License.
> > > -->
> > > <scxml xmlns="http://www.w3.org/2005/07/scxml"
> > >      version="1.0"
> > >      initialstate="start">
> > >
> > >    <parallel id="start">
> > >
> > >        <state id="simulatedUser">
> > >            <datamodel>
> > >                <data name="one" expr="1" />
> > >                <data name="two" expr="2" />
> > >            </datamodel>
> > >
> > >            <onentry>
> > >                <send event="event.bar" namelist="one two" delay="1ms"/>
> > >            </onentry>
> > >            <transition event="event.bar">
> > >                <log label="'simulatedUser'"
> > > expr="_eventdatamap['event.bar'].one + ', ' +
> > > _eventdatamap['event.bar'].two"/>
> > >            </transition>
> > >        </state>
> > >
> > >        <state id="counter">
> > >            <initial>
> > >                <transition target="twenty"/>
> > >            </initial>
> > >
> > >            <state id="twenty">
> > >                <transition event="event.bar"
> > >                    cond="_eventdatamap['event.bar'].one +
> > > _eventdatamap['event.bar'].two eq 3"
> > >                    target="thirty"/>
> > >                <transition event="event.bar">
> > >                    <log label="'event.bar in twenty state'"
> > > expr="_eventdatamap['event.bar'].one + ', ' +
> > > _eventdatamap['event.bar'].two"/>
> > >                </transition>
> > >            </state>
> > >
> > >            <state id="thirty" final="true"/>
> > >        </state>
> > >
> > >    </parallel>
> > >
> > > </scxml>
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> > For additional commands, e-mail: user-help@commons.apache.org
> >
> >
>

Re: [SCXML] Possible bug passing _eventdatamap across parallel contexts when event has delay

Posted by Roger Hoover <ro...@gmail.com>.
Rahul,

Thanks for the quick response.  More questions/comments inline.

On Fri, Nov 7, 2008 at 11:54 AM, Rahul Akolkar <ra...@gmail.com>wrote:

> On Thu, Nov 6, 2008 at 10:38 PM, Roger Hoover <ro...@gmail.com>
> wrote:
> > Hi,
> >
> > I'm new to Commons SCXML but I ran into what looks like a bug to me.
>  When
> > an event generated in one context gets sent to a sibling context with a
> > delay, the _eventdata object is null.  Oddly enough, when delay unset or
> set
> > to 0ms, it works fine.  I created a test file based on eventdata-03.xml
> to
> > expose it.   Set delay="0ms" and the counter state machine makes it to
> the
> > thirty state.  Set delay="1ms" and it doesn't.
> >
> <snip/>
>
> A slight digression, but might be relevant background -- the
> EventDispatcher [1] (which handles <send> and <cancel>) is anticipated
> to be user-authored for any usages of the library of reasonable
> complexity. We do provide simple examples (see implementing classes in
> Javadoc) as a way to get folks started, but these do not handle any
> targettypes beyond 'scxml' (which is also the default).
>

Does Commons SCXML support the 'basichttp' targettype?  If not, is there an
open source EventDispatcher for basichttp already out there that you know
of?


>
> The behavior you mention above does seem like a bug. Obviously, events
> with or without delay are handled differently (the former are
> scheduled for execution). I suspect the SimpleScheduler implementation
> may be overlooking event payloads, or not processing them correctly.
> Please file a bug report in JIRA [2] and attach your test case, and
> I'll take a look at this.


Thanks.  I filed a JIRA here. https://issues.apache.org/jira/browse/SCXML-87

>
>
> -Rahul
>
> [1]
> http://commons.apache.org/scxml/0.8/apidocs/org/apache/commons/scxml/EventDispatcher.html
> [2] http://commons.apache.org/scxml/issue-tracking.html
>
>
> > Any help is appreciated.  Thanks,
> >
> > Roger
> >
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <!--
> >  * Licensed to the Apache Software Foundation (ASF) under one or more
> >  * contributor license agreements.  See the NOTICE file distributed with
> >  * this work for additional information regarding copyright ownership.
> >  * The ASF licenses this file to You under the Apache License, Version
> 2.0
> >  * (the "License"); you may not use this file except in compliance with
> >  * the License.  You may obtain a copy of the License at
> >  *
> >  *     http://www.apache.org/licenses/LICENSE-2.0
> >  *
> >  * Unless required by applicable law or agreed to in writing, software
> >  * distributed under the License is distributed on an "AS IS" BASIS,
> >  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> >  * See the License for the specific language governing permissions and
> >  * limitations under the License.
> > -->
> > <scxml xmlns="http://www.w3.org/2005/07/scxml"
> >      version="1.0"
> >      initialstate="start">
> >
> >    <parallel id="start">
> >
> >        <state id="simulatedUser">
> >            <datamodel>
> >                <data name="one" expr="1" />
> >                <data name="two" expr="2" />
> >            </datamodel>
> >
> >            <onentry>
> >                <send event="event.bar" namelist="one two" delay="1ms"/>
> >            </onentry>
> >            <transition event="event.bar">
> >                <log label="'simulatedUser'"
> > expr="_eventdatamap['event.bar'].one + ', ' +
> > _eventdatamap['event.bar'].two"/>
> >            </transition>
> >        </state>
> >
> >        <state id="counter">
> >            <initial>
> >                <transition target="twenty"/>
> >            </initial>
> >
> >            <state id="twenty">
> >                <transition event="event.bar"
> >                    cond="_eventdatamap['event.bar'].one +
> > _eventdatamap['event.bar'].two eq 3"
> >                    target="thirty"/>
> >                <transition event="event.bar">
> >                    <log label="'event.bar in twenty state'"
> > expr="_eventdatamap['event.bar'].one + ', ' +
> > _eventdatamap['event.bar'].two"/>
> >                </transition>
> >            </state>
> >
> >            <state id="thirty" final="true"/>
> >        </state>
> >
> >    </parallel>
> >
> > </scxml>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

Re: [SCXML] Possible bug passing _eventdatamap across parallel contexts when event has delay

Posted by Rahul Akolkar <ra...@gmail.com>.
On Thu, Nov 6, 2008 at 10:38 PM, Roger Hoover <ro...@gmail.com> wrote:
> Hi,
>
> I'm new to Commons SCXML but I ran into what looks like a bug to me.  When
> an event generated in one context gets sent to a sibling context with a
> delay, the _eventdata object is null.  Oddly enough, when delay unset or set
> to 0ms, it works fine.  I created a test file based on eventdata-03.xml to
> expose it.   Set delay="0ms" and the counter state machine makes it to the
> thirty state.  Set delay="1ms" and it doesn't.
>
<snip/>

A slight digression, but might be relevant background -- the
EventDispatcher [1] (which handles <send> and <cancel>) is anticipated
to be user-authored for any usages of the library of reasonable
complexity. We do provide simple examples (see implementing classes in
Javadoc) as a way to get folks started, but these do not handle any
targettypes beyond 'scxml' (which is also the default).

The behavior you mention above does seem like a bug. Obviously, events
with or without delay are handled differently (the former are
scheduled for execution). I suspect the SimpleScheduler implementation
may be overlooking event payloads, or not processing them correctly.
Please file a bug report in JIRA [2] and attach your test case, and
I'll take a look at this.

-Rahul

[1] http://commons.apache.org/scxml/0.8/apidocs/org/apache/commons/scxml/EventDispatcher.html
[2] http://commons.apache.org/scxml/issue-tracking.html


> Any help is appreciated.  Thanks,
>
> Roger
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!--
>  * Licensed to the Apache Software Foundation (ASF) under one or more
>  * contributor license agreements.  See the NOTICE file distributed with
>  * this work for additional information regarding copyright ownership.
>  * The ASF licenses this file to You under the Apache License, Version 2.0
>  * (the "License"); you may not use this file except in compliance with
>  * the License.  You may obtain a copy of the License at
>  *
>  *     http://www.apache.org/licenses/LICENSE-2.0
>  *
>  * Unless required by applicable law or agreed to in writing, software
>  * distributed under the License is distributed on an "AS IS" BASIS,
>  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>  * See the License for the specific language governing permissions and
>  * limitations under the License.
> -->
> <scxml xmlns="http://www.w3.org/2005/07/scxml"
>      version="1.0"
>      initialstate="start">
>
>    <parallel id="start">
>
>        <state id="simulatedUser">
>            <datamodel>
>                <data name="one" expr="1" />
>                <data name="two" expr="2" />
>            </datamodel>
>
>            <onentry>
>                <send event="event.bar" namelist="one two" delay="1ms"/>
>            </onentry>
>            <transition event="event.bar">
>                <log label="'simulatedUser'"
> expr="_eventdatamap['event.bar'].one + ', ' +
> _eventdatamap['event.bar'].two"/>
>            </transition>
>        </state>
>
>        <state id="counter">
>            <initial>
>                <transition target="twenty"/>
>            </initial>
>
>            <state id="twenty">
>                <transition event="event.bar"
>                    cond="_eventdatamap['event.bar'].one +
> _eventdatamap['event.bar'].two eq 3"
>                    target="thirty"/>
>                <transition event="event.bar">
>                    <log label="'event.bar in twenty state'"
> expr="_eventdatamap['event.bar'].one + ', ' +
> _eventdatamap['event.bar'].two"/>
>                </transition>
>            </state>
>
>            <state id="thirty" final="true"/>
>        </state>
>
>    </parallel>
>
> </scxml>
>

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