processi

about processes and engines

when and more

There’s an expression in OpenWFE that’s not much known but that yields some power, it’s the <when> expression.

It’s been used to implement some of the workflow patterns, especially those requiring a strong touch of process calculus.

I had forgotten in the documentation to mention the ‘whenFrequency’ parameter of the expression pool, which sets how frequently the engine (well, its expression pool service) checks for the validity of a when expression. This lack of documentation got fixed.

So why bringing ‘process calculus’ on the table ? <when> can be used to receive messages whereas <set> is used to send them.

<process-definition name="flow1" revision="0.1">
    <sequence>
        <set variable="//channel_z" value="the message" />
    </sequence>
</process-definition>

<process-definition name="flow2" revision="0.1">
    <when>
        <defined variable-value="//channel_z" />
        <sequence>
            <set field="message" variable-value="//channel_z" />
            <participant ref="someone" />
        </sequence>
    </when>
</process-definition>

In this small example, a process ‘flow1’ sends a message to process ‘flow2’ via a variable set at the engine level (hence the ‘//’ in front of its name).

Well, passing only a String message is constraining. By using the <save> expression, you could pass a whole workitem as the message :

<process-definition name="flow1" revision="0.2">
    <sequence>
        <save to-variable="//channel_z" />
    </sequence>
</process-definition>

<process-definition name="flow2" revision="0.2">
    <when>
        <defined variable-value="//channel_z" />
        <sequence>
            <restore from-variable="//channel_z" />
            <participant ref="someone" />
        </sequence>
    </when>
</process-definition>

The workitem sent to participant ‘someone’ will be a copy of the workitem saved by ‘flow1’.

This ‘via variable’ channel mechanism is limited to an engine. A new mechanism is currently in inception that will bring cross-engine channels.

Written by John Mettraux

August 6, 2006 at 11:43 am

Posted in openwfe, workflow

%d bloggers like this: