org.apache.camel.model
Class LoadBalanceDefinition

java.lang.Object
  extended by org.apache.camel.model.OptionalIdentifiedDefinition<Type>
      extended by org.apache.camel.model.ProcessorDefinition<LoadBalanceDefinition>
          extended by org.apache.camel.model.LoadBalanceDefinition
All Implemented Interfaces:
Block, NamedNode

public class LoadBalanceDefinition
extends ProcessorDefinition<LoadBalanceDefinition>

Represents an XML <loadBalance/> element


Field Summary
 
Fields inherited from class org.apache.camel.model.ProcessorDefinition
inheritErrorHandler, log
 
Constructor Summary
LoadBalanceDefinition()
           
 
Method Summary
protected  Processor createOutputsProcessor(RouteContext routeContext, Collection<ProcessorDefinition<?>> outputs)
           
 Processor createProcessor(RouteContext routeContext)
          Override this in definition class and implement logic to create the processor based on the definition model.
 LoadBalanceDefinition custom(String ref)
          Uses the custom load balancer
 LoadBalanceDefinition failover()
          Uses fail over load balancer

Will not round robin and inherit the error handler.

 LoadBalanceDefinition failover(Class<?>... exceptions)
          Uses fail over load balancer

Will not round robin and inherit the error handler.

 LoadBalanceDefinition failover(int maximumFailoverAttempts, boolean inheritErrorHandler, boolean roundRobin, Class<?>... exceptions)
          Uses fail over load balancer
 String getLabel()
          Returns a label to describe this node such as the expression if some kind of expression node
 LoadBalancerDefinition getLoadBalancerType()
           
 List<ProcessorDefinition<?>> getOutputs()
           
 String getRef()
           
 String getShortName()
          Returns a short name for this node which can be useful for ID generation or referring to related resources like images
 boolean isOutputSupported()
           
 LoadBalanceDefinition loadBalance(LoadBalancer loadBalancer)
          Uses a custom load balancer
 LoadBalanceDefinition random()
          Uses random load balancer
 LoadBalanceDefinition roundRobin()
          Uses round robin load balancer
 void setLoadBalancerType(LoadBalancerDefinition loadbalancer)
           
 void setOutputs(List<ProcessorDefinition<?>> outputs)
           
 void setRef(String ref)
           
 LoadBalanceDefinition sticky(Expression correlationExpression)
          Uses sticky load balancer
 LoadBalanceDefinition topic()
          Uses topic load balancer
 String toString()
           
 LoadBalanceDefinition weighted(boolean roundRobin, String distributionRatio)
          Uses weighted load balancer
 LoadBalanceDefinition weighted(boolean roundRobin, String distributionRatio, String distributionRatioDelimiter)
          Uses weighted load balancer
 
Methods inherited from class org.apache.camel.model.ProcessorDefinition
addInterceptStrategies, addInterceptStrategy, addOutput, addRoutes, aggregate, aggregate, aggregate, aggregate, aop, attribute, bean, bean, bean, bean, beanRef, beanRef, choice, clearOutput, configureChild, convertBodyTo, convertBodyTo, createChannel, createChildProcessor, createCompositeProcessor, createOutputsProcessor, delay, delay, delay, doTry, dynamicRouter, dynamicRouter, end, endChoice, endDoTry, endParent, enrich, enrich, enrichRef, filter, filter, filter, filter, getInterceptStrategies, getNodeFactory, getOtherAttributes, getParent, id, idempotentConsumer, idempotentConsumer, idempotentConsumer, inheritErrorHandler, inOnly, inOnly, inOnly, inOnly, inOnly, inOnly, inOut, inOut, inOut, inOut, inOut, inOut, isAbstract, isInheritErrorHandler, loadBalance, log, log, log, log, loop, loop, loop, makeProcessor, markRollbackOnly, markRollbackOnlyLast, marshal, marshal, marshal, marshal, multicast, multicast, multicast, onCompletion, onException, onException, pipeline, pipeline, pipeline, pipeline, placeholder, policy, policy, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrichRef, preCreateProcessor, process, processRef, recipientList, recipientList, recipientList, recipientList, removeFaultHeader, removeHeader, removeHeaders, removeHeaders, removeProperty, resequence, resequence, resolveKnownConstantFields, resolvePropertyPlaceholders, rollback, rollback, routeId, routingSlip, routingSlip, routingSlip, routingSlip, routingSlip, routingSlip, routingSlip, sample, sample, sample, setBody, setBody, setExchangePattern, setFaultBody, setFaultHeader, setHeader, setHeader, setInheritErrorHandler, setNodeFactory, setOtherAttributes, setOutHeader, setOutHeader, setParent, setProperty, setProperty, sort, sort, sort, split, split, split, stop, threads, threads, threads, threads, throttle, throttle, throwException, to, to, to, to, to, to, to, to, to, to, toF, transacted, transacted, transform, transform, unmarshal, unmarshal, unmarshal, unmarshal, validate, validate, validate, wireTap, wireTap, wireTap, wireTap, wireTap, wireTap, wireTap, wrapChannel, wrapInErrorHandler, wrapProcessor
 
Methods inherited from class org.apache.camel.model.OptionalIdentifiedDefinition
description, getDescription, getDescriptionText, getId, hasCustomIdAssigned, idOrCreate, setDescription, setId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LoadBalanceDefinition

public LoadBalanceDefinition()
Method Detail

getShortName

public String getShortName()
Description copied from class: OptionalIdentifiedDefinition
Returns a short name for this node which can be useful for ID generation or referring to related resources like images

Specified by:
getShortName in interface NamedNode
Overrides:
getShortName in class OptionalIdentifiedDefinition<LoadBalanceDefinition>
Returns:
defaults to "node" but derived nodes should overload this to provide a unique name

getOutputs

public List<ProcessorDefinition<?>> getOutputs()
Specified by:
getOutputs in class ProcessorDefinition<LoadBalanceDefinition>

setOutputs

public void setOutputs(List<ProcessorDefinition<?>> outputs)

isOutputSupported

public boolean isOutputSupported()
Specified by:
isOutputSupported in class ProcessorDefinition<LoadBalanceDefinition>

getRef

public String getRef()

setRef

public void setRef(String ref)

getLoadBalancerType

public LoadBalancerDefinition getLoadBalancerType()

setLoadBalancerType

public void setLoadBalancerType(LoadBalancerDefinition loadbalancer)

createOutputsProcessor

protected Processor createOutputsProcessor(RouteContext routeContext,
                                           Collection<ProcessorDefinition<?>> outputs)
                                    throws Exception
Overrides:
createOutputsProcessor in class ProcessorDefinition<LoadBalanceDefinition>
Throws:
Exception

createProcessor

public Processor createProcessor(RouteContext routeContext)
                          throws Exception
Description copied from class: ProcessorDefinition
Override this in definition class and implement logic to create the processor based on the definition model.

Overrides:
createProcessor in class ProcessorDefinition<LoadBalanceDefinition>
Throws:
Exception

loadBalance

public LoadBalanceDefinition loadBalance(LoadBalancer loadBalancer)
Uses a custom load balancer

Overrides:
loadBalance in class ProcessorDefinition<LoadBalanceDefinition>
Parameters:
loadBalancer - the load balancer
Returns:
the builder

failover

public LoadBalanceDefinition failover()
Uses fail over load balancer

Will not round robin and inherit the error handler.

Returns:
the builder

failover

public LoadBalanceDefinition failover(Class<?>... exceptions)
Uses fail over load balancer

Will not round robin and inherit the error handler.

Parameters:
exceptions - exception classes which we want to failover if one of them was thrown
Returns:
the builder

failover

public LoadBalanceDefinition failover(int maximumFailoverAttempts,
                                      boolean inheritErrorHandler,
                                      boolean roundRobin,
                                      Class<?>... exceptions)
Uses fail over load balancer

Parameters:
maximumFailoverAttempts - maximum number of failover attempts before exhausting. Use -1 to newer exhaust when round robin is also enabled. If round robin is disabled then it will exhaust when there are no more endpoints to failover
inheritErrorHandler - whether or not to inherit error handler. If false then it will failover immediately in case of an exception
roundRobin - whether or not to use round robin (which keeps state)
exceptions - exception classes which we want to failover if one of them was thrown
Returns:
the builder

weighted

public LoadBalanceDefinition weighted(boolean roundRobin,
                                      String distributionRatio)
Uses weighted load balancer

Parameters:
roundRobin - used to set the processor selection algorithm.
distributionRatio - String of weighted ratios for distribution of messages.
Returns:
the builder

weighted

public LoadBalanceDefinition weighted(boolean roundRobin,
                                      String distributionRatio,
                                      String distributionRatioDelimiter)
Uses weighted load balancer

Parameters:
roundRobin - used to set the processor selection algorithm.
distributionRatio - String of weighted ratios for distribution of messages.
distributionRatioDelimiter - String containing delimiter to be used for ratios
Returns:
the builder

roundRobin

public LoadBalanceDefinition roundRobin()
Uses round robin load balancer

Returns:
the builder

random

public LoadBalanceDefinition random()
Uses random load balancer

Returns:
the builder

custom

public LoadBalanceDefinition custom(String ref)
Uses the custom load balancer

Parameters:
ref - reference to lookup a custom load balancer from the Registry to be used.
Returns:
the builder

sticky

public LoadBalanceDefinition sticky(Expression correlationExpression)
Uses sticky load balancer

Parameters:
correlationExpression - the expression for correlation
Returns:
the builder

topic

public LoadBalanceDefinition topic()
Uses topic load balancer

Returns:
the builder

getLabel

public String getLabel()
Description copied from class: ProcessorDefinition
Returns a label to describe this node such as the expression if some kind of expression node

Overrides:
getLabel in class ProcessorDefinition<LoadBalanceDefinition>

toString

public String toString()
Overrides:
toString in class Object


Apache CAMEL