<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Distributed Systems on AsherSu's Blog</title><link>https://ashersu.cn/en/categories/distributed-systems/</link><description>Recent content in Distributed Systems on AsherSu's Blog</description><generator>Hugo -- gohugo.io</generator><language>en-US</language><lastBuildDate>Tue, 24 Nov 2026 00:00:00 +0800</lastBuildDate><atom:link href="https://ashersu.cn/en/categories/distributed-systems/index.xml" rel="self" type="application/rss+xml"/><item><title>Enterprise Integration Patterns: Channels, Routing, and Transformation</title><link>https://ashersu.cn/en/posts/enterprise-integration-patterns/</link><pubDate>Tue, 24 Nov 2026 00:00:00 +0800</pubDate><guid>https://ashersu.cn/en/posts/enterprise-integration-patterns/</guid><description>&lt;p&gt;Enterprise Integration Patterns provide a shared vocabulary for connecting systems without turning every integration into a one-off design. The value of the patterns is not the diagram itself, but the explicit ownership, delivery semantics, and failure behavior behind it.&lt;/p&gt;&#10;&lt;h2 id="messages-and-channels"&gt;&lt;a href="#messages-and-channels" class="header-anchor"&gt;&lt;/a&gt;Messages and channels&#13;&#10;&lt;/h2&gt;&lt;p&gt;Applications in a distributed system cannot share process memory. They exchange messages that normally contain:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;A header with metadata such as an identifier, timestamp, correlation ID, and routing information.&lt;/li&gt;&#10;&lt;li&gt;A body containing the business payload.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Channels isolate business flows. Commands, domain events, queries, and bulk data transfers should not be mixed into one undifferentiated stream because they have different consumers, priorities, and retry expectations.&lt;/p&gt;&#10;&lt;h2 id="pipes-and-filters"&gt;&lt;a href="#pipes-and-filters" class="header-anchor"&gt;&lt;/a&gt;Pipes and filters&#13;&#10;&lt;/h2&gt;&lt;p&gt;The Pipes and Filters pattern decomposes a complex flow into independent processing stages.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;A filter validates, enriches, decrypts, or transforms a message.&lt;/li&gt;&#10;&lt;li&gt;A pipe transfers a message between filters.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Filters should be stateless whenever practical. Stateless stages are easier to scale horizontally, retry, and test. If a stage requires state, the consistency boundary and replay behavior must be explicit.&lt;/p&gt;&#10;&lt;h2 id="message-routers"&gt;&lt;a href="#message-routers" class="header-anchor"&gt;&lt;/a&gt;Message routers&#13;&#10;&lt;/h2&gt;&lt;p&gt;A router decides where a message goes without changing its business content. Common routing strategies include:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Static routing for stable, predefined destinations.&lt;/li&gt;&#10;&lt;li&gt;Content-based routing using fields in the header or payload.&lt;/li&gt;&#10;&lt;li&gt;Context-based routing using service health, tenant, region, or runtime policy.&lt;/li&gt;&#10;&lt;li&gt;Dynamic routing where rules are maintained by a control plane.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Routing rules are business rules. They need versioning, tests, monitoring, and a fallback path for messages that match no destination.&lt;/p&gt;&#10;&lt;h2 id="message-translation"&gt;&lt;a href="#message-translation" class="header-anchor"&gt;&lt;/a&gt;Message translation&#13;&#10;&lt;/h2&gt;&lt;p&gt;Systems often disagree at several levels:&lt;/p&gt;&#10;&lt;table&gt;&#10;&#9;&lt;thead&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;Level&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;Example&lt;/th&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/thead&gt;&#10;&#9;&lt;tbody&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Transport&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;HTTP to JMS&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Representation&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;XML to JSON&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Data type&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;String to integer&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Business structure&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;External order model to internal payment model&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;p&gt;Keep translation at integration boundaries. Allowing an external model to spread through the domain layer couples core business logic to another system&amp;rsquo;s schema.&lt;/p&gt;&#10;&lt;h2 id="splitter-and-aggregator"&gt;&lt;a href="#splitter-and-aggregator" class="header-anchor"&gt;&lt;/a&gt;Splitter and aggregator&#13;&#10;&lt;/h2&gt;&lt;p&gt;A splitter turns one composite message into multiple smaller messages. An aggregator combines related messages into one result.&lt;/p&gt;&#10;&lt;p&gt;Both patterns require a correlation identifier. Aggregation also needs a completion rule:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Expected message count reached.&lt;/li&gt;&#10;&lt;li&gt;A final marker received.&lt;/li&gt;&#10;&lt;li&gt;A time window expired.&lt;/li&gt;&#10;&lt;li&gt;A business-specific condition became true.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Timeout behavior matters as much as the successful path. The system must decide whether to return a partial result, retry missing parts, send the message to manual handling, or fail the entire operation.&lt;/p&gt;&#10;&lt;h2 id="reliability-and-idempotency"&gt;&lt;a href="#reliability-and-idempotency" class="header-anchor"&gt;&lt;/a&gt;Reliability and idempotency&#13;&#10;&lt;/h2&gt;&lt;p&gt;Most message systems provide at-least-once delivery in real deployments. Consumers must therefore tolerate duplicates.&lt;/p&gt;&#10;&lt;p&gt;Useful controls include:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;A business idempotency key.&lt;/li&gt;&#10;&lt;li&gt;A consumed-message table or deduplication cache.&lt;/li&gt;&#10;&lt;li&gt;Transactional outbox for atomically persisting business state and an event.&lt;/li&gt;&#10;&lt;li&gt;Retry policies with backoff and a maximum attempt count.&lt;/li&gt;&#10;&lt;li&gt;Dead-letter handling with enough context for replay.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Exactly-once business outcomes usually come from idempotent application design, not from assuming the broker will deliver every message exactly once.&lt;/p&gt;&#10;&lt;h2 id="observability"&gt;&lt;a href="#observability" class="header-anchor"&gt;&lt;/a&gt;Observability&#13;&#10;&lt;/h2&gt;&lt;p&gt;An integration flow should expose:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Message and correlation IDs.&lt;/li&gt;&#10;&lt;li&gt;Current stage and destination.&lt;/li&gt;&#10;&lt;li&gt;Processing duration per stage.&lt;/li&gt;&#10;&lt;li&gt;Retry count and final failure reason.&lt;/li&gt;&#10;&lt;li&gt;Queue depth, consumer lag, and dead-letter volume.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Structured logs and distributed tracing must avoid recording passwords, tokens, personal data, or full payment payloads.&lt;/p&gt;&#10;&lt;p&gt;The practical goal is a flow where routing, transformation, retries, and ownership are visible. A pattern is useful only when operators can understand what happened to a message after production traffic becomes imperfect.&lt;/p&gt;&#10;</description></item></channel></rss>