Skip to content

Content Enricher and Content Filter

Systems exchange messages, which are packages of data sent between applications. A sender’s message rarely matches what the receiver needs. Two patterns fix this in opposite directions.

Content Enricher. It handles the case where the sender does not have all the data items the receiver requires. The enricher adds the missing items to the message before it moves on.

An enricher can work in two ways:

  • It computes the missing data itself and needs no external source. This form is very similar to a Message Translator, which converts a message from one format to another.
  • It fetches the data from elsewhere. Apache Camel’s Enrich EIP is the most common example. It uses a producer, a component that calls out to get data. Camel caches producers for reuse. You can set the cache size or turn the cache off.

Content Filter. It handles the opposite problem. A message is large, but the receiver cares about only a few items. The filter strips the unimportant items and keeps the important ones. The pattern description notes that surprisingly many situations call for removing data.

The two patterns are mirror images. One grows a message. The other shrinks it.

An order system sends a message with a customer ID and a list of items. A shipping system needs the customer’s delivery address, which the order system does not hold. An enricher gets the address and adds it to the message.

The same message also carries many order details that shipping ignores. A filter removes them. Shipping receives a smaller message with only what it needs.

The verified facts say little about costs. One point follows from how enrichment works: an enricher that fetches data relies on a producer to reach another source. Camel lets you tune or disable its producer cache, so caching is a setting you can choose.

A message gains missing data in the enricher, then loses unneeded data in the filter.

Diagram source
flowchart LR
A[Sender message] --> E[Content Enricher]
S[(Other source)] -.-> E
E --> F[Content Filter]
F --> R[Receiver]
  • Where a receiver needs data the sender does not hold, the document names an enrichment step that supplies it.
  • Where receivers need only a few items from a large message, the document names a filtering step that removes the rest.
  • Where enrichment calls another source through Camel’s Enrich EIP, the document states the producer cache setting.