commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rahul Akolkar <>
Subject Re: SCXML: "external" vs. "internal" events
Date Thu, 06 Aug 2009 04:19:18 GMT
On Wed, Aug 5, 2009 at 5:41 PM, Renaud, Martin<> wrote:
> Hi (again...)
> In the examples/usecases provided on the scxml site, the events are
> fired from outside the state machine. I called them "external" events.
> Is it valid to trigger events from inside my state machine sub-class, in
> a state handler method?  As I understand it, those events should be
> queued after any pending events (if any). However, it seems that those
> "internal" events are not processed.

Actually, there are well-defined semantics for the phrases external
and internal WRT events when it comes to SCXML.

I think you're saying events are being triggered via state handlers
(which is Java code) while the existing event is being processed. In
the latest release of Commons SCXML (v0.9), the executor does not
maintain an external event queue. As application code, you'd have to
maintain an event queue and add events from the handlers to said
queue, and trigger these on the executor while the queue has elements.
There is an open ticket to add such a queue to the executor
implementation for the next release (no planned date yet).

If you want to consider triggering events using SCXML markup, you can
consider using the <send> element. For example, see this test case in
v0.9 (long URL, may get fragmented in email):

> Side question, if an event if fired but it is not
> relevant/applicable/configured for the machine current state, is there a
> way to have an exception to be thrown?

Strictly speaking, this is not an interesting case in state machine
theory (it simply gets ignored as no transitions take place), but I do
agree it may be useful information for certain applications. Theres
atleast a couple of ways to deal with this:

 * Add a wildcard transition at a common ancestor state like so:

 <scxml ... initial="main">
    <state id="main">
       <transition event="*">
          <!-- log as illustration, do whatever is needed here -->
          <log expr="Unmatched event"/>

       <!-- The rest of the original state machine -->


 * Register an SCXMLListener and check if any onTransition() callback
is received when an event is triggered.


> I can provide config + code to illustrate my point, but I'd like to be
> sure it suppose to work first.
> Thanks,
> Martin

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message