xpath is always causing problem for people.
The xpath library uses their own types by default so often a xpath result is a NodeList, Node etc. But what you want is just plain text, eg a String type.
So you need to tell the xpath expression to use String as result type
<xpath resultType="String"> ... </xpath>
The sticky load balancer will always pick the same one as last time, eg it does a hash of the correlation expressions which yields the same for the same expression.
If you want failover etc. you need to build you own custom strategy.
And to see the value for the xpath, you can set it as a header value before the load balancer. Then you can see the header value when you have enabled the Camel tracer, in the logs.
<setHeader headerName="foo"> <xpath ...> </setHeader> <loadBalance> ...
Thanks for replying.
I tried tracing the request and response. But Foo is present only in my request, it is not present in my responses. Usually the first request does not contains the ServiceGroupID, the response contains it. And camel is searching for the xpath expression only in the request. How can make it search for the expression in the responses instead?
Any help would really be appreciated.
Edited by: spaniard89 on Sep 18, 2012 1:32 PM
Response from whom? You mean the http endpoint you load balance over?
So what should happen on the initial call from the client? There is no session yet. In that case the correlation expression would be empty, which mean the sticky load balancer will pick (I assume the 1st one, but it depends on the hashing).
The http endpoint would see this is a new client, and put the session id, in its response, which Camel return to the caller.
The next time the caller calls, he must include the session id in the SOAP message, so the xpath expression can grab it.
But the problem now is that the sticky load balancer hashing algorithm may not yield the same http server as before, because the correlation expression is different.
You would have to write a custom load balancer or custom correlation expression to take into account the issue with the initial call so you can pick the same http server when you have the actual session id.
First of all, thanks for logging a ticket.
How can I build my own custom load balancer, which would ignore the first request and would search for the expression in the response? A basic outline with function that might be useful to me, would be really beneficial. And how can I play around with requests and responses?
The Camel in Action book, covers how to develop a custom load balancer, in section 8.6.4.
You can extend the SimpleLoadBalancerSupport class, and in choose processor method you pick the http endpoint, eg the logic to pick the same based on session id.
And in the process method, you will after the process(exchange) being invoked on the chose processor, do the xpath stuff.