Flexible Webservice Orchestration on Talend ESB using Apache Camel’s Content Enricher Functionality

A couple of months ago, I presented how to implement a simple orchestration case on Talend ESB using Apache Camel and Apache CXF. This reference implementation expects all endpoints to be available at all time, otherwise the request would fail. Often, a target system might not always be reachable or mandatory for the required orchestration case. A possible scenario would be, that you like to add additional information about the customer if available (for the case that he was already a customer in the past), before calling another webservice. For such situations, Apache Camel’s Content Enricher is a useful component.

(Image from: http://camel.apache.org/content-enricher.html)

According to the official documentation:

Enrich uses a Producer to obtain the additional data. It is usually used for Request Reply messaging, for instance to invoke an external web service.

It lets you clone your message, routing it to a second endpoint. You can then merge both messages into one, “enriching” your previous message with the content of the second system. At this point, you might also decide that due to insufficient response you want to discard the enriched data for this webservice call.

PlantUML diagram

Surrounding the enricher call with a Exception Cause, gives you the ability to ignore the remote call whenever the call led to any kind of exception. (Or you can route your enriching call to a different route, handling the exception)

This setup lets you build flexible systems. However, if for your webservice case the remote system is indispensable, you might want to have a look at Apache MQ to implement guarantee of delivery.