Choosing The Right Route Pattern
Route patterns are the main way Klok standardizes integration behavior. Choose the simplest pattern that matches the data flow and operational constraints.
Pattern Decision Tree
Standard Patterns
KlokOnrampRoute
Use when bringing data into Klok from an external system and publishing a CloudEvent to the broker. It should transform Class X to Class B or C.
KlokChannelAdapterSourceRoute
Use when the ingress should only convert the protocol and put the payload on the broker as received. That is good design when it is motivated: you must accept every call from a system without losing a message, so the route does as little as possible; the message then waits on the topic, can be processed several times, and survives a receiving system that is down. A processing route or the egress maps it later. The solution document says why, which leg maps, and that no other system or domain reads the topic as its contract.
Example: Postmark's inbound webhook feeds the AI customer service of Bidevind, Klok Kollega, barnbok-ai, biljett-shop
and QuickRace. Solution KLK006 Messaging Services is designed with a channel adapter per account
(KLK006I<n>_PostmarkInbound<Account> in klok-postmark-ingress), which receives the call and puts it on a topic, so
that a mail never bounces while QuickRace is redeployed; an egress delivers each message to the right inbox later. See
Ingress, egress, onramp and channel
adapter.
KlokProcessingRoute
Use for internal broker-to-broker logic: enrichment, splitting, aggregation, validation, schema bridges, tenant bridges, or other transformations that do not directly touch an external system.
KlokOfframpRoute
Use when consuming from a broker topic and delivering to an external target system. It should transform Class B or C to target Class X at the last moment.
KlokCustomRoute
Use only when the standard patterns are insufficient. A custom route should still use framework logging, error handling, CloudEvent behavior, and observability conventions.
Specialized Patterns
KlokOnrampRouteSync: request-reply at ingress when the caller requires a response.KlokOfframpRouteSync: request-reply toward a target system.KlokChannelAdapterSinkRoute: an egress that only converts the protocol and delivers the payload unchanged.KlokEnrichSubRoute: side-service enrichment.KlokSchemaUpgradeBridgeandKlokSchemaDowngradeBridge: transition between model versions.KlokTenantBridgeRoute: cross-tenant translation and controlled sharing.- Splitter and aggregator patterns: batch/event conversion.
Pattern Smells
- Choosing Custom because the standard pattern is unfamiliar.
- Using Sync Bridge to avoid changing a caller that could be asynchronous.
- Publishing Class X from an onramp when other systems or domains will read it.
- A channel adapter that lets Class X onto the broker without a reason in the solution document, or whose topic other domains read.
- Hiding business transformation inside an adapter.
- Creating a processing route that keeps important state in memory.