Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Stardust/Knowledge Base/Integration/Camel/Exception Handling in Generic Camel Application"

(Created page with "== Overview == 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 e...")
 
(Use Case)
Line 6: Line 6:
  
 
Process Diagram:
 
Process Diagram:
 
+
[[File:CATExcp1.JPG]]
 
+
 
+
  
 
== How To ==
 
== How To ==

Revision as of 01:34, 12 May 2014

Overview

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">
   <constant>http://customer1.enterprise12.qa.sungardims.net/Apollo/rest/auth/token?loginName=ccuser&amp;operatorId=1937&amp;httpClient.authenticationPreemptive=true
</constant>
</setHeader>
<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:

<onException>
<exception>java.lang.Exception</exception>
  <handled>
    <constant>true</constant>
  </handled>
<log message="Me Got again new $simple{property.CamelExceptionCaught.message}" />
<setHeader headerName="Message">
<simple>$simple{property.CamelExceptionCaught.message}</simple>
</setHeader>
<simple>exception=null</simple>
<setProperty propertyName="CamelExceptionCaught">
<simple>null</simple>
</setProperty>
</onException>

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

Back to the top