Enterprise Integration Patterns With MuleSoft: Message Enricher
Learn how to enrich your data with everything you need.
Join the DZone community and get the full member experience.Join For Free
Message or Content Enricher is an enterprise integration pattern that receives an incoming message that doesn't have all the required information, then retrieves that required information from another target system appends it to the data to the message, or forms a new message with everything we need. The image below demonstrates the basic flow.
MuleSoft 3 provides the Message Enricher component. Generally, we wrap the message processor with the Message Enricher component to enrich the data.
In MuleSoft 4, there is no component like the Message Enricher — it has been removed. This component is replaced by the Target and Target Value attributes with the message processor.
- Target is the basically variable that holds the data (output data of the processor). Names can only include numbers, characters, and underscores.
- Target Value is output data of the processor that is stored within the target variable. By default, the value is the message payload (
payload). The field accepts any value that a variable accepts: any supported data type, DataWeave expressions, the keywords
message, but not the keyword
One use case is if you don't want to change your actual payload when a request has been processed by a particular processor.
We receive the request with the payload and, after it passes through one of the processors, the payload will be the output of that processor, but we don't want to change the actual payload. In such cases, you can make use of the Target and Target Value, and the output of that processor will be stored in the Target variable instead of replacing the actual payload with the output of the processor.
Here is a video tutorial explaining step by step how to enrich data with Target and Target Values in MuleSoft.
Now you know how to implement a Message Enricher with MuleSoft.
Opinions expressed by DZone contributors are their own.