Skip to content
GitHub

Tasks

Tasks are the atomic units of work in a Fleans workflow. Each task maps to a <bpmn:*Task> element and runs exactly once per activation. Fleans supports four task variants; Send, Receive, Manual and Business Rule tasks are not implemented — see Unsupported task types below.

See also: BPMN Support matrix for the full coverage table.


Each task type reaches the WorkflowInstance its own way: plain tasks wait for a REST completion, scripts run in the evaluator, user tasks wait for a person, and service tasks run on a gRPC worker. Open interactive diagram ↗

A Plain Task (<bpmn:task>) has no executor: the token waits on it until something calls POST /Execution/complete-activity with the instance id and the task’s ActivityId — the same external-completion pattern as a service task without a type. Use it for work done outside the engine that a system reports back over REST.

BPMN:

<bpmn:task id="Task_1" name="Do something" />
Plain Task BPMN diagramPlain Task BPMN diagram

A Script Task (<bpmn:scriptTask scriptFormat="csharp">) executes a C# expression via DynamicExpresso. The script is read from the <bpmn:script> child element (a script inside <extensionElements>, such as <camunda:script>, is ignored) and evaluated against a _context variable bag that exposes the current workflow variables. C# (scriptFormat csharp, c# or omitted) is built in. Any other format — such as javascript — runs on an external worker plugin; see Other script languages.

BPMN:

<bpmn:scriptTask id="Task_1" name="Compute total" scriptFormat="csharp">
<bpmn:script>_context.total = _context.price * _context.qty</bpmn:script>
</bpmn:scriptTask>
Script Task BPMN diagramScript Task BPMN diagram

A script in any format other than C# runs outside the engine, on an external-task worker registered for the task type fleans.script.<format> (the format in lower case; js means javascript and py means python). A runaway, memory-hungry or malicious script cannot then hurt the engine, and the worker scales and upgrades on its own.

scriptFormatWorker
csharp, c#, omittedBuilt in
javascript, jsFleans.Plugins.JavaScript from fleans-plugins — see JavaScript script tasks
anything elseAny worker you write for fleans.script.<format>
<bpmn:scriptTask id="Task_1" name="Compute total" scriptFormat="javascript">
<bpmn:script><![CDATA[
const total = _context.items.reduce((sum, i) => sum + i.price * i.qty, 0);
_context.total = total;
_context.label = `order-${_context.orderId}`;
]]></bpmn:script>
</bpmn:scriptTask>
  • The worker receives the script and every visible variable, and sends back only the top-level variables the script changed; those merge into the scope, and the rest keep their type.
  • ${…} is not rewritten in these formats — in JavaScript it is template-literal syntax.
  • The script is checked by the worker when it runs, not at deploy. A deploy with no worker connected for the format succeeds with a warning; the task waits until a worker connects.
  • A script that throws fails the activity with code 500 and the script’s message. A worker may also fail it with a BPMN error code, which an error boundary event catches.
  • Each run is an external-task round trip (tens of milliseconds) rather than an in-process call.

A User Task (<bpmn:userTask>) suspends the workflow and waits for a human to act. Fleans exposes a claim → complete (or fail / cancel) lifecycle via REST and the admin UI.

BPMN:

<!-- Requires xmlns:camunda="http://camunda.org/schema/1.0/bpmn" on <bpmn:definitions> -->
<bpmn:userTask id="Task_1" name="Approve request"
camunda:assignee="manager"
camunda:candidateGroups="approvers" />
User Task BPMN diagramUser Task BPMN diagram

A Service Task (<bpmn:serviceTask type="…">) delegates execution to a handler identified by the type attribute. It runs on a worker connected over gRPC — your own, or the ready-made plugins’ image; the engine images bundle none — and its result comes back through <fleans:output> bindings.

BPMN:

<!-- Requires xmlns:fleans="https://fleans.io/schema/bpmn/1.0" on <bpmn:definitions> -->
<bpmn:serviceTask id="Task_1" name="Call external API">
<bpmn:extensionElements>
<fleans:taskDefinition type="rest-call" />
<fleans:ioMapping>
<fleans:input source="=apiUrl" target="url" />
<fleans:output source="=__response.body" target="result" />
</fleans:ioMapping>
</bpmn:extensionElements>
</bpmn:serviceTask>
Service Task BPMN diagramService Task BPMN diagram

The type value must match the task type a worker registers — rest-call above is the REST Caller plugin from fleans-plugins. To learn more:

A <bpmn:serviceTask> with no type attribute and no taskDefinition is not dispatched anywhere: it waits for POST /Execution/complete-activity, like a plain task — see Service Tasks.


Every task type accepts <fleans:ioMapping>: inputs compute task-local variables from C# expressions before the task runs, and outputs pick what it hands back to the process. See Input/Output Mapping.


Send Task (<bpmn:sendTask>), Receive Task (<bpmn:receiveTask>), Manual Task (<bpmn:manualTask>) and Business Rule Task (<bpmn:businessRuleTask>) are not implemented. The converter does not recognise them: the element is skipped and every sequence flow to or from it is dropped, so the process deploys without an error but with a gap — a token that should reach the element stops where the dropped flow started. Model the step with a supported task instead (for example a service task for a send, or a message intermediate catch event for a receive).