org.apache.camel.processor.loadbalancer
Class StickyLoadBalancer
java.lang.Object
org.apache.camel.impl.ServiceSupport
org.apache.camel.processor.loadbalancer.LoadBalancerSupport
org.apache.camel.processor.loadbalancer.QueueLoadBalancer
org.apache.camel.processor.loadbalancer.StickyLoadBalancer
- All Implemented Interfaces:
- AsyncProcessor, Processor, LoadBalancer, Service
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:
- $Revision: 41844 $
Methods inherited from class org.apache.camel.impl.ServiceSupport |
addChildService, getThreadName, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, nextThreadCounter, removeChildService, start, stop |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
StickyLoadBalancer
public StickyLoadBalancer()
StickyLoadBalancer
public StickyLoadBalancer(Expression<Exchange> correlationExpression)
StickyLoadBalancer
public StickyLoadBalancer(Expression<Exchange> correlationExpression,
QueueLoadBalancer loadBalancer)
setCorrelationExpression
public void setCorrelationExpression(Expression<Exchange> correlationExpression)
setLoadBalancer
public void setLoadBalancer(QueueLoadBalancer loadBalancer)
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
Copyright © 2008 IONA Open Source Community. All Rights Reserved.