| <?xml version="1.0" encoding="UTF-8"?> |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| <beans xmlns="http://www.springframework.org/schema/beans" |
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| xsi:schemaLocation=" |
| http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd |
| http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd |
| "> |
| |
| <camelContext xmlns="http://camel.apache.org/schema/spring"> |
| <endpoint id="bad" uri="jetty:http://localhost:8871/bar"/> |
| <endpoint id="bad2" uri="jetty:http://localhost:8872/bad2"/> |
| <endpoint id="good" uri="jetty:http://localhost:8873/good"/> |
| <endpoint id="good2" uri="jetty:http://localhost:8874/good2"/> |
| |
| <!-- START SNIPPET: e1 --> |
| <route> |
| <from uri="direct:start"/> |
| <!-- load balance using failover in round robin mode. |
| Also do not inherit error handler which means the failover LB will not fallback |
| and use error handler but trigger failover to next endpoint immediately --> |
| <loadBalance inheritErrorHandler="false"> |
| <failover roundRobin="true"/> |
| <!-- and this is the four endpoints we will load balance with failover --> |
| <to ref="bad"/> |
| <to ref="bad2"/> |
| <to ref="good"/> |
| <to ref="good2"/> |
| </loadBalance> |
| </route> |
| <!-- END SNIPPET: e1 --> |
| |
| <route> |
| <from ref="bad"/> |
| <to uri="mock:bad"/> |
| <setHeader headerName="CamelHttpResponseCode"><constant>500</constant></setHeader> |
| <setBody><constant>Something bad happened</constant></setBody> |
| </route> |
| |
| <route> |
| <from ref="bad2"/> |
| <to uri="mock:bad2"/> |
| <setHeader headerName="CamelHttpResponseCode"><constant>404</constant></setHeader> |
| <setBody><constant>Not found</constant></setBody> |
| </route> |
| |
| <route> |
| <from ref="good"/> |
| <to uri="mock:good"/> |
| <setBody><constant>Good</constant></setBody> |
| </route> |
| |
| <route> |
| <from ref="good2"/> |
| <to uri="mock:good2"/> |
| <setBody><constant>Also good</constant></setBody> |
| </route> |
| |
| </camelContext> |
| |
| </beans> |