Package org.apache.camel.processor.loadbalancer

Examples of org.apache.camel.processor.loadbalancer.CircuitBreakerLoadBalancer


    public CircuitBreakerLoadBalancerDefinition() {
    }

    @Override
    protected LoadBalancer createLoadBalancer(RouteContext routeContext) {
        CircuitBreakerLoadBalancer answer;

        if (!exceptions.isEmpty()) {
            List<Class<?>> classes = new ArrayList<Class<?>>();
            for (String name : exceptions) {
                Class<?> type = routeContext.getCamelContext().getClassResolver().resolveClass(name);
                if (type == null) {
                    throw new IllegalArgumentException("Cannot find class: " + name + " in the classpath");
                }
                if (!ObjectHelper.isAssignableFrom(Throwable.class, type)) {
                    throw new IllegalArgumentException("Class is not an instance of Throwable: " + type);
                }
                classes.add(type);
            }
            answer = new CircuitBreakerLoadBalancer(classes);
        } else {
            answer = new CircuitBreakerLoadBalancer();
        }

        if (getHalfOpenAfter() != null) {
            answer.setHalfOpenAfter(getHalfOpenAfter());
        }
        if (getThreshold() != null) {
            answer.setThreshold(getThreshold());
        }
        return answer;
    }
View Full Code Here


     * @param halfOpenAfter     time interval in milliseconds for half open state.
     * @param exceptions        exception classes which we want to break if one of them was thrown
     * @return the builder
     */
    public LoadBalanceDefinition circuitBreaker(int threshold, long halfOpenAfter, Class<?>... exceptions) {
        CircuitBreakerLoadBalancer breakerLoadBalancer = new CircuitBreakerLoadBalancer(Arrays.asList(exceptions));
        breakerLoadBalancer.setThreshold(threshold);
        breakerLoadBalancer.setHalfOpenAfter(halfOpenAfter);

        setLoadBalancerType(new LoadBalancerDefinition(breakerLoadBalancer));
        return this;
    }
View Full Code Here

TOP

Related Classes of org.apache.camel.processor.loadbalancer.CircuitBreakerLoadBalancer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.