processi

about processes and engines

lose and forget

Fire and forget ? No, lose and forget. These are two new expressions of the OpenWFE process definition language (1.7.1pre8).

It all started when a customer told me : “OK, I send a workitem to this user, and after the user replied, I want a notification email to be sent to that unit. But if the user hasn’t used the workitem within 5 days, I want the notification email to be emitted anyway. When the user will finally reply, I don’t want the email to be sent a second time”.

That called for a concurrence combined with its ‘count’ attribute.

I started with that :

<process-definition name="flow_segment" revision="0.1">
    <sequence>
        <!-- ... first part of the flow  -->
        <concurrence count="1">
            <participant ref="lazy-one" />
            <subprocess ref="delayed-mail" forget="true" />
        </concurrence>

        <if test="${email-sent} == false">
            <participant ref="send-email" />
        </if>
        <!-- remaining part of the flow ... -->
    </sequence>

    <process-definition name="delayed-mail">
        <sequence>
            <sleep for="5d" />
            <participant ref="send-email" />
            <set variable="/email-sent" value="true" />
        </sequence>
    </process-definition>
</process-definition>

This leverages the forget=”true” attribute of the <subprocess> expression.

But I don’t like that definition, it’s not concise enough.

At first, I considered adding a ‘forget’ attribute to all expressions, after all <participant> and <subprocess> already have it. But it would be awkward.
It needed something elegant (as always), something more readable. The flow became :

<process-definition name="flow_segment" revision="0.2">
    <sequence>
        <!-- ... first part of the flow  -->
        <concurrence>
            <participant ref="lazy-one" />
            <forget>
                <sequence>
                    <sleep for="5d" />
                    <participant ref="send-email" />
                    <set variable="email-sent" value="true" />
                </sequence>
            </forget>
        </concurrence>

        <if test="${email-sent} == false">
            <participant ref="send-email" />
        </if>
        <!-- remaining part of the flow ... -->
    </sequence>
</process-definition>

The <forget> expression triggers (applies) its child expression (in an independent thread of execution) and replies immediately (hence no need for the ‘count’ attribute in the concurrence).
this flow is (IMHO) easier to read than the former, having inlined the ‘send mail after 5 days’ behaviour.

The <lose> expression, triggers its child expression, but never replies to its engine. It can be cancelled though.

I’ll post more about potential usage of <lost> and <forget> later.

Switzerland 2 – South Korea 0 :-)

Written by John Mettraux

June 23, 2006 at 10:52 pm

Posted in openwfe, technical, workflow

One Response

Subscribe to comments with RSS.

  1. […] I noticed that an error slipped in my yesterday’s post (well there are probably more errors). […]


Comments are closed.

%d bloggers like this: