Class LoadBalanceDefinition

  • All Implemented Interfaces:
    org.apache.camel.CamelContextAware, org.apache.camel.LineNumberAware, Block, OutputNode, org.apache.camel.NamedNode, 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 Detail

      • LoadBalanceDefinition

        public LoadBalanceDefinition()
    • Method Detail

      • setLoadBalancerType

        public void setLoadBalancerType​(LoadBalancerDefinition loadbalancer)
        The load balancer to be used
      • 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
      • 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