🎋Parallel mode
# The basic example
If you want to execute the three components a, b, c in parallel, you can use the WHEN
keyword. It should be noted that WHEN
must be capitalized.
<chain name="chain1">
WHEN(a, b, c);
</chain>
# Nested with serial (1)
Let's combine THEN
and WHEN
to see an example:
<chain name="chain1">
THEN(
a,
WHEN(b, c, d),
e
);
</chain>
Flow chart
In the above example, e will be executed only after b, c, and d.
# Nested with serial (2)
The above example should be well understood, so let's look at another example:
<chain name="chain1">
THEN(
a,
WHEN(b, THEN(c, d)),
e
);
</chain>
Flow chart
# Ignore errors
The WHEN
keyword provides a subkeyword ignoreError
(defaults to false) to provide the feature of ignoring errors. The usage is as follows:
<chain name="chain1">
THEN(
a,
WHEN(b, c, d).ignoreError(true),
e
);
</chain>
Flow chart
The above assumes that any node in b, c, and d has an exception, then eventually e will still be executed.
# Any node is executed first and other nodes are ignored
The WHEN
keyword provides a sub-keyword any
(default is false) to provide the feature that in the parallel process, any node is executed first, ignoring other node and continuing to execute. The usage is as follows:
<chain name="chain1">
THEN(
a,
WHEN(b, THEN(c, d), e).any(true),
f
);
</chain>
Flow chart
In the above process, if node e is executed first, then node f will be executed immediately regardless of whether other nodes are executed.
# The concept of groups
In previous versions, parallel mode had the concept of groups, and in version 2.8.X, we removed the concept of groups.
With EL expressions, you actually write 2 different WHENs as 2 groups. for example:
<chain name="chain1">
THEN(
WHEN(a, b, c, d)
);
</chain>
The above abcd are all in the same parallel group.
<chain name="chain1">
THEN(
WHEN(a, b),
WHEN(c, d)
);
</chain>
In the above example, ab is a parallel group and cd is another parallel group.