org.apache.camel.processor.loadbalancer
Class StickyLoadBalancer
java.lang.Object
org.apache.camel.support.ServiceSupport
org.apache.camel.processor.loadbalancer.LoadBalancerSupport
org.apache.camel.processor.loadbalancer.QueueLoadBalancer
org.apache.camel.processor.loadbalancer.StickyLoadBalancer
- All Implemented Interfaces:
- AsyncProcessor, Navigate<Processor>, Processor, LoadBalancer, Service, ShutdownableService, StatefulService, SuspendableService
public class StickyLoadBalancer
- extends QueueLoadBalancer
Implements a sticky load balancer using an Expression
to calculate
a correlation key to perform the sticky load balancing; rather like jsessionid in the web
or JMSXGroupID in JMS.
- Version:
Methods inherited from class org.apache.camel.support.ServiceSupport |
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspended, isSuspending, resume, shutdown, start, stop, suspend |
StickyLoadBalancer
public StickyLoadBalancer(Expression correlationExpression)
StickyLoadBalancer
public StickyLoadBalancer(Expression correlationExpression,
QueueLoadBalancer loadBalancer)
getCorrelationExpression
public Expression getCorrelationExpression()
chooseProcessor
protected Processor chooseProcessor(List<Processor> processors,
Exchange exchange)
- Specified by:
chooseProcessor
in class QueueLoadBalancer
removeProcessor
public void removeProcessor(Processor processor)
- Description copied from interface:
LoadBalancer
- Removes the given processor from the load balancer
- Specified by:
removeProcessor
in interface LoadBalancer
- Overrides:
removeProcessor
in class LoadBalancerSupport
- Parameters:
processor
- the processor to be removed from the load balancer
getNumberOfHashGroups
public int getNumberOfHashGroups()
setNumberOfHashGroups
public void setNumberOfHashGroups(int numberOfHashGroups)
getStickyKey
protected Object getStickyKey(Object value)
- A strategy to create the key for the sticky load balancing map.
The default implementation uses the hash code of the value
then modulos by the numberOfHashGroups to avoid the sticky map getting too big
- Parameters:
value
- the correlation value
- Returns:
- the key to be used in the sticky map
toString
public String toString()
- Overrides:
toString
in class Object
Apache CAMEL