Content Enricher
A Content Enricher augments a message with data fetched from an external source so receivers get the complete information they need without burdening the producer. It adds latency and an external dependency, often mitigated with caching.
A Content Enricher adds information to a message that the original sender did not include but the receiver needs. It retrieves the missing data from an external resource — a database, a service, or a cache — and merges it into the message before forwarding.
The problem it solves is incomplete messages. Producers often send only what they naturally know. A purchase event might carry a customer id but not the customer's address or credit tier, while a downstream fulfillment or fraud system needs those details. Rather than burden the producer, an enricher fills the gap at the integration layer.
How It Works
The enricher reads the incoming message, extracts a key or correlation value, queries an external source for the additional data, and writes that data into an enriched copy of the message. The lookup may be synchronous (call a service and wait) or backed by a local cache for speed. The output message contains the original content plus the new fields.
The enricher is conceptually a translator that adds rather than reshapes. It must handle lookup failures: missing reference data, timeouts, or stale caches, deciding whether to proceed, route to an error channel, or retry.
{ customerId: 42 } --> [Enricher: lookup customer] --> { customerId:42, tier:'GOLD', region:'EU' }
When to Use It
Use it when downstream consumers need data the producer cannot or should not supply, when joining event streams with reference data, or when decorating messages with computed or looked-up context. It is common in stream processing (stream-table joins) and in ETL pipelines.
Avoid enriching with data that changes faster than the message can use it, and avoid heavy synchronous lookups on high-throughput paths without caching.
Trade-offs
Enrichment introduces an external dependency into the message path, adding latency and a failure mode: the source may be slow or unavailable. Caching mitigates latency but risks staleness. The enricher also couples the pipeline to the external schema. The benefit is keeping producers simple while giving consumers complete messages.
Related Patterns
It is the opposite of the Content Filter, which removes data. A Message Translator reshapes format; an enricher adds content. A Normalizer may precede it. An Aggregator combines messages, whereas an enricher combines a message with external data.
Example
A Kafka Streams pipeline joins an orders stream with a customers table (a KTable). For each order it looks up the customer's loyalty tier and shipping region and emits an enriched order event that the fulfillment service can act on without further queries.