Skip to content

5.5.2.1.3. Merge Node

Mikołaj Milewski edited this page Nov 12, 2026 · 1 revision

Merge Node

A Merge Node brings alternative incoming flows back to one outgoing path. It does not synchronize the alternatives: an arrival on any input can continue. In UML it is drawn as a diamond, like a Decision Node, but its edge direction is converging rather than branching.

flowchart LR
    choose{Decision}
    choose -->|approved| card(Card payment)
    choose -->|else| transfer(Bank transfer)
    card --> merge{Merge}
    transfer --> merge
    merge --> receipt(Send receipt)
Loading

Mermaid approximation: this diagram shows the model's routing, not a complete UML Activity notation. Rounded boxes represent actions; edge labels identify token types or guards. Mermaid does not provide native Activity node semantics.

Definition

.AddDecision<Payment>(decision => decision
    .AddFlow("CardPayment", flow => flow.AddGuard(async c => c.Token.Method == "card"))
    .AddElseFlow("BankTransfer"))
.AddAction(
    "CardPayment",
    async c => c.Output(await payments.ChargeCardAsync(
        c.GetTokensOfType<Payment>().Single(), c.CancellationToken)),
    node => node.AddFlow<Receipt, MergeNode>())
.AddAction(
    "BankTransfer",
    async c => c.Output(await payments.TransferAsync(
        c.GetTokensOfType<Payment>().Single(), c.CancellationToken)),
    node => node.AddFlow<Receipt, MergeNode>())
.AddMerge(merge => merge.AddFlow<Receipt>("SendReceipt"))
.AddAction("SendReceipt", async c =>
    await receipts.SendAsync(c.GetTokensOfType<Receipt>().Single(), c.CancellationToken))

The Merge Node forwards an arriving alternative; it does not wait for all its inputs. The default options for control nodes do not add implicit joining. Use a Join Node when multiple concurrent branches must all arrive first.

Clone this wiki locally