Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
bhalchandraswcg
Contributor
8,673

Previous – Envelope Wrapper | Index | Next – Content Filter


This week, we'll study yet another Message Transformation pattern known as Content Enricher.

When do I use this pattern?


Content Enricher pattern, as the name suggests, enriches the content of the message by adding related information to it. For example, when order is sent from one system to another, the customer information can be added to the message. This adding of customer information to order is known as enriching the content and the pattern is said to be Content Enricher pattern.

Content Enricher in CPI


CPI has a dedicated component for Content Enricher. And, I'll be using Northwind service to enrich Orders with Customer information.

Integration Flow



Enriching Order with Customer Details


This integration flow starts immediately using a Timer Start, gets the Orders from an Order Management System (OMS) using Command Message pattern, enriches the orders with customer information from Customer Relationship Management (CRM) system using Content Enricher component, and Logs the output using Groovy Script. Note that, in this example, Northwind is acting as Order Management System (OMS) and Customer Relationship Management (CRM).

Here's the configuration of OData Adapter for getting the orders:




























Tab Property Value
Connection Address https://services.odata.org/V2/Northwind/Northwind.svc
Connection CSRF Protected Unchecked
Processing Operation Details Query (GET)
Processing Resource Path Orders

This is the configuration of the OData Adapter for enriching with customer information:




























Tab Property Value
Connection Address https://services.odata.org/V2/Northwind/Northwind.svc
Connection CSRF Protected Unchecked
Processing Operation Details Query (GET)
Processing Resource Path Customers

Finally, the Content Enricher component is configured as:

































Tab Property Value

Processing
Aggregation Algorithm Enrich

Processing
Path to Node /Orders/Order

Processing
Key Element CustomerID

Processing
Path to Node /Customers/Customer

Processing
Key Element CustomerID

Output


When the orders are fetched the payload looks like below:
<Orders>
<Order>
<RequiredDate>1996-08-01T00:00:00.000</RequiredDate>
<ShipName>Vins et alcools Chevalier</ShipName>
<ShippedDate>1996-07-16T00:00:00.000</ShippedDate>
<ShipCity>Reims</ShipCity>
<CustomerID>VINET</CustomerID>
<ShipVia>3</ShipVia>
<ShipPostalCode>51100</ShipPostalCode>
<OrderID>10248</OrderID>
<OrderDate>1996-07-04T00:00:00.000</OrderDate>
<ShipRegion/>
<ShipAddress>59 rue de l&apos;Abbaye</ShipAddress>
<ShipCountry>France</ShipCountry>
<EmployeeID>5</EmployeeID>
<Freight>32.3800</Freight>
</Order>
<Order>
<RequiredDate>1996-08-16T00:00:00.000</RequiredDate>
<ShipName>Toms Spezialitäten</ShipName>
<ShippedDate>1996-07-10T00:00:00.000</ShippedDate>
<ShipCity>Münster</ShipCity>
<CustomerID>TOMSP</CustomerID>
<ShipVia>1</ShipVia>
<ShipPostalCode>44087</ShipPostalCode>
<OrderID>10249</OrderID>
<OrderDate>1996-07-05T00:00:00.000</OrderDate>
<ShipRegion/>
<ShipAddress>Luisenstr. 48</ShipAddress>
<ShipCountry>Germany</ShipCountry>
<EmployeeID>6</EmployeeID>
<Freight>11.6100</Freight>
</Order>
...
</Orders>

The Customers payload looks like below:
<Customers>
<Customer>
<CompanyName>Vins et alcools Chevalier</CompanyName>
<Address>59 rue de l'Abbaye</Address>
<Phone>26.47.15.10</Phone>
<Region/>
<PostalCode>51100</PostalCode>
<Country>France</Country>
<CustomerID>VINET</CustomerID>
<City>Reims</City>
<Fax>26.47.15.11</Fax>
<ContactName>Paul Henriot</ContactName>
<ContactTitle>Accounting Manager</ContactTitle>
</Customer>
<Customer>
<CompanyName>Toms Spezialitäten</CompanyName>
<Address>Luisenstr. 48</Address>
<Phone>0251-031259</Phone>
<Region/>
<PostalCode>44087</PostalCode>
<Country>Germany</Country>
<CustomerID>TOMSP</CustomerID>
<City>Münster</City>
<Fax>0251-035695</Fax>
<ContactName>Karin Josephs</ContactName>
<ContactTitle>Marketing Manager</ContactTitle>
</Customer>
...
</Customers>

Now the Content Enricher component matches CustomerID 'VINET' under /Orders/Order with CustomerID 'VINET' under /Customers/Customer, matches CustomerID 'TOMSP' under /Orders/Order with CustomerID 'TOMSP' under /Customers/Customer, and so on. The output payload after Content Enricher looks like below. Notice how Customer tag with matching CustomerID is added under each Order tag, this is how Order is enriched with the Customer information.
<Orders>
<Order>
<RequiredDate>1996-08-01T00:00:00.000</RequiredDate>
<ShipName>Vins et alcools Chevalier</ShipName>
<ShippedDate>1996-07-16T00:00:00.000</ShippedDate>
<ShipCity>Reims</ShipCity>
<CustomerID>VINET</CustomerID>
<Customer>
<CompanyName>Vins et alcools Chevalier</CompanyName>
<Address>59 rue de l'Abbaye</Address>
<Phone>26.47.15.10</Phone>
<Region/>
<PostalCode>51100</PostalCode>
<Country>France</Country>
<CustomerID>VINET</CustomerID>
<City>Reims</City>
<Fax>26.47.15.11</Fax>
<ContactName>Paul Henriot</ContactName>
<ContactTitle>Accounting Manager</ContactTitle>
</Customer>
<ShipVia>3</ShipVia>
<ShipPostalCode>51100</ShipPostalCode>
<OrderID>10248</OrderID>
<OrderDate>1996-07-04T00:00:00.000</OrderDate>
<ShipRegion/>
<ShipAddress>59 rue de l'Abbaye</ShipAddress>
<ShipCountry>France</ShipCountry>
<EmployeeID>5</EmployeeID>
<Freight>32.3800</Freight>
</Order>
<Order>
<RequiredDate>1996-08-16T00:00:00.000</RequiredDate>
<ShipName>Toms Spezialitäten</ShipName>
<ShippedDate>1996-07-10T00:00:00.000</ShippedDate>
<ShipCity>Münster</ShipCity>
<CustomerID>TOMSP</CustomerID>
<Customer>
<CompanyName>Toms Spezialitäten</CompanyName>
<Address>Luisenstr. 48</Address>
<Phone>0251-031259</Phone>
<Region/>
<PostalCode>44087</PostalCode>
<Country>Germany</Country>
<CustomerID>TOMSP</CustomerID>
<City>Münster</City>
<Fax>0251-035695</Fax>
<ContactName>Karin Josephs</ContactName>
<ContactTitle>Marketing Manager</ContactTitle>
</Customer>
<ShipVia>1</ShipVia>
<ShipPostalCode>44087</ShipPostalCode>
<OrderID>10249</OrderID>
<OrderDate>1996-07-05T00:00:00.000</OrderDate>
<ShipRegion/>
<ShipAddress>Luisenstr. 48</ShipAddress>
<ShipCountry>Germany</ShipCountry>
<EmployeeID>6</EmployeeID>
<Freight>11.6100</Freight>
</Order>
...
</Orders>

Limitations of the Content Enricher component


The Content Enricher component supports only XML data format and only SuccessFactors, Soap1.x, and OData adapter types. However, there is a way to overcome this and I discussed it a couple of years ago in my blog Cloud Platform Integration: Enrich your content with ProcessDirect.

Conclusion


Content Enricher is a Message Transformation pattern used to enrich the content with information from a third server. Content Enricher component implements the Content Enricher pattern in CPI.

References/Further Readings



Hope this helps,
Bala

Previous – Envelope Wrapper | Index | Next – Content Filter

3 Comments
Labels in this area