Skip to content

Instantly share code, notes, and snippets.

@bibryam
Last active October 16, 2015 13:32
Show Gist options
  • Select an option

  • Save bibryam/085f6ef765b5cebecab7 to your computer and use it in GitHub Desktop.

Select an option

Save bibryam/085f6ef765b5cebecab7 to your computer and use it in GitHub Desktop.
Camel jBPM Error Handler Route
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