1 /* 2 * Copyright 2008 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.openehealth.ipf.platform.camel.core.camel.exception; 17 18 19 import org.apache.camel.spring.SpringRouteBuilder; 20 import org.openehealth.ipf.platform.camel.core.support.processor.FailureProcessor; 21 22 23 /** 24 * @author Martin Krasser 25 */ 26 public class ErrorHandlingRouteBuilder extends SpringRouteBuilder { 27 28 private FailureProcessor failure = new FailureProcessor("blah"); 29 30 31 @Override 32 public void configure() throws Exception { 33 34 // global error handler 35 errorHandler(noErrorHandler()); 36 37 from("direct:input-1") 38 .to("mock:inter") // inherits global error handler (step in pipeline) 39 .process(failure) // inherits global error handler (step in pipeline) 40 .to("mock:output"); // inherits global error handler (step in pipeline) 41 42 from("direct:input-2") 43 // defines local error handler (placed before every node in this route) 44 .errorHandler(defaultErrorHandler().maximumRedeliveries(2)).to("mock:error") 45 .onException(Exception.class).handled(false).end() 46 .to("mock:inter") // no redeliveries here 47 .to("direct:temp"); // the error handler of this node redelivers 48 49 from("direct:temp") 50 .to("mock:check") // inherits global error handler (step in pipeline) 51 .process(failure) // inherits global error handler (step in pipeline) 52 .to("mock:output"); // inherits global error handler (step in pipeline) 53 } 54 55 }