I am building a load balancer for http requests using apache camel 2.12.2. For this I am using camel-servlet, camel-http components and my route definition is like:
<from uri="servlet:///my/path?matchOnUriPrefix=true" />
<loadBalance inheritErrorHandler="false">
<failover roundRobin="true" maximumFailoverAttempts="2">
<exception>java.io.IOException</exception>
</failover>
<to uri="http://server1:9090?bridgeEndpoint=true&throwExceptionOnFailure=false" />
<to uri="http://server2:9090?bridgeEndpoint=true&throwExceptionOnFailure=false" />
<to uri="http://server3:9090?bridgeEndpoint=true&throwExceptionOnFailure=false" />
</loadBalance>
Now I am trying to implement caching for http requests using Memcached. For this, I am trying to use RoutePolicy. Is it possible to break the exchange and return back from onExchangeBegin when there is a cache hit, without hitting http end points? Or is there any better way to implement caching for http requests using Memcached?
I tried camel-cache component, but we cannot use EHCache as we already have Memcached in our project.