Class LoadBalanceDefinition

All Implemented Interfaces:
org.apache.camel.CamelContextAware, org.apache.camel.LineNumberAware, Block, OutputNode, org.apache.camel.NamedNode, org.apache.camel.spi.HasCamelContext, org.apache.camel.spi.HasId, org.apache.camel.spi.IdAware

@Metadata(label="eip,routing") public class LoadBalanceDefinition extends OutputDefinition<LoadBalanceDefinition>
Balances message processing among a number of nodes
  • Constructor Details

    • LoadBalanceDefinition

      public LoadBalanceDefinition()
  • Method Details

    • getOutputs

      public List<ProcessorDefinition<?>> getOutputs()
      Overrides:
      getOutputs in class OutputDefinition<LoadBalanceDefinition>
    • setOutputs

      public void setOutputs(List<ProcessorDefinition<?>> outputs)
      Overrides:
      setOutputs in class OutputDefinition<LoadBalanceDefinition>
    • getLoadBalancerType

      public LoadBalancerDefinition getLoadBalancerType()
    • setLoadBalancerType

      public void setLoadBalancerType(LoadBalancerDefinition loadbalancer)
      The load balancer to be used
    • loadBalance

      public LoadBalanceDefinition loadBalance(org.apache.camel.processor.loadbalancer.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
    • failover

      public LoadBalanceDefinition failover(int maximumFailoverAttempts, boolean inheritErrorHandler, boolean roundRobin, boolean sticky, 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)
      sticky - whether or not to use sticky (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(org.apache.camel.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
    • getShortName

      public String getShortName()
      Specified by:
      getShortName in interface org.apache.camel.NamedNode
      Overrides:
      getShortName in class OutputDefinition<LoadBalanceDefinition>
    • 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
      Specified by:
      getLabel in interface org.apache.camel.NamedNode
      Overrides:
      getLabel in class ProcessorDefinition<LoadBalanceDefinition>
    • toString

      public String toString()
      Overrides:
      toString in class OutputDefinition<LoadBalanceDefinition>