1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.platform.camel.core.camel.exception;
17
18 import org.apache.camel.Processor;
19 import org.apache.camel.spring.SpringRouteBuilder;
20 import org.openehealth.ipf.platform.camel.core.support.processor.ExceptionProcessor;
21
22
23
24
25
26 public class ExceptionHandlingRouteBuilder extends SpringRouteBuilder {
27
28 @Override
29 public void configure() throws Exception {
30
31 from("direct:input")
32
33
34
35
36 .onException(Exception1.class).to("mock:error1").end()
37 .onException(Exception2.class).to("mock:error2").end()
38 .onException(Exception.class).to("mock:error3").end()
39 .process(exceptionProcessor())
40 .to("mock:success");
41 }
42
43 private Processor exceptionProcessor() {
44 ExceptionProcessor result = new ExceptionProcessor();
45 result.getExceptions().put("blah", new Exception1());
46 result.getExceptions().put("blub", new Exception2());
47 result.getExceptions().put("oink", new Exception3());
48 return result;
49 }
50 }