Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: for the plan.

Jump to: navigation, search

Stardust/Knowledge Base/Integration/Camel/Exception Handling in Generic Camel Application


In this article we are going to discuss, how we can handle exception in Generic Camel Application and propogate it to Stardust process, also how we can gather exception data (e.g. exception message) and set it to Stardust process data for further processing during process execution.

Use Case

Lets take an example, we have a Generic Camel Application that is calling a REST service, during execution of this application there are chances that execption may occur (network issue, service unavailable, wrong user credentials etc.). Our aim is to catch thsi exception and set certain process data and use that process data in the process to define different transitions (process flow), for example, if the process data named exceptionMessages is not null (which it will only be if there is an execption in calling the REST service), we need to define process flow to an activity that will manage the exceptional cases.

Process Diagram: CATExcp1.JPG

How To

To define a Generic Camel Application Type to call a REST service the route is like:

<setHeader headerName="CamelHttpMethod"><constant>GET</constant></setHeader>
<setHeader headerName="CamelHttpUri">
<to uri="http://isoverwritten?authMethod=Digest&amp;authUsername=ccuser@customer1&amp;authPassword=ccpassword"/> 
<convertBodyTo type="java.lang.String"/>

And to handle the exception one needs to add the following route in the above mentioned route:

<setHeader headerName="Message">
<setProperty propertyName="CamelExceptionCaught">

Once this is done, one can set the parameter to get the exception message named "Message" and store the value in Stardust process data. CATExcp2.JPG

Model can be found here File:TestModel (3).zip

Back to the top