Last active
October 16, 2015 13:32
-
-
Save bibryam/085f6ef765b5cebecab7 to your computer and use it in GitHub Desktop.
Camel jBPM Error Handler Route
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void configure() { | |
| from("timer://trigger?fixedRate=true&period=500&repeatCount=10").routeId("mainRoute") | |
| .to("log:com.ofbizian.jbpm.before?showAll=true&multiline=true") | |
| .process(new Processor() { | |
| @Override | |
| public void process(Exchange exchange) throws Exception { | |
| throw new RuntimeException("Something went wrong"); | |
| } | |
| }); | |
| onException(Exception.class) | |
| .handled(true) | |
| .process(new Processor() { | |
| @Override | |
| public void process(Exchange exchange) throws Exception { | |
| final Map map = new HashMap(); | |
| map.putAll(exchange.getIn().getHeaders()); | |
| map.put("contextId", exchange.getContext().getName()); | |
| map.put("routeId", exchange.getProperty(Exchange.FAILURE_ROUTE_ID)); | |
| map.put("endpointId", exchange.getProperty(Exchange.FAILURE_ENDPOINT)); | |
| map.put("exchangeId", exchange.getExchangeId()); | |
| map.put("breadcrumbId", exchange.getIn().getHeader(Exchange.BREADCRUMB_ID)); | |
| map.put("exceptionType", exchange.getProperty(Exchange.EXCEPTION_CAUGHT).getClass()); | |
| map.put("errorMessage", exchange.getProperty(Exchange.EXCEPTION_CAUGHT).toString()); | |
| exchange.getOut().setHeader("CamelJBPMParameters", map); | |
| } | |
| }) | |
| .to("jbpm:http://localhost:8080/business-central?userName=bpmsAdmin&password=password&deploymentId=org.kie.example:camel-process:1.0.0-SNAPSHOT&processId=project1.camel.demo"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment