-
15. Re: Fabric load balancing endpoint?
wbailey Jun 19, 2012 11:05 AM (in response to davsclaus)Thank you for your comments and the example it is helping a lot. I've now got the following setup.
Client 'loadbalancer':
<reference id="zkClient" interface="org.linkedin.zookeeper.client.IZKClient" /> <camelContext trace="false" id="camel" xmlns="http://camel.apache.org/schema/blueprint"> <route id="loadbalancer"> <from uri="jetty:http://0.0.0.0:8184/simplelbservice"></from> <log message="Request received : ${body}"></log> <to uri="fabric:simpleservice"></to> </route> </camelContext>
Server:
<bean id="basicWebServiceImpl" class="com.monitise.WebService" /> <reference id="zkClient" interface="org.linkedin.zookeeper.client.IZKClient"></reference> <camelContext id="camel" trace="false" xmlns="http://camel.apache.org/schema/blueprint"> <route id="server"> <from uri="fabric:simpleservice:jetty:http://0.0.0.0:8185/simpleservice"></from> <log message="Request received : ${body}"></log> <process ref="basicWebServiceImpl"></process> </route> </camelContext>
The server part works fine, but if I hit the client exposed Jetty endpoint I end up with the following exception:
java.lang.IllegalArgumentException: !Absolute URI: /simplelbservice at org.eclipse.jetty.client.HttpExchange.setURI(HttpExchange.java:591) at org.eclipse.jetty.client.HttpExchange.setURL(HttpExchange.java:414) at org.apache.camel.component.jetty.JettyHttpProducer.createHttpExchange(JettyHttpProducer.java:98) at org.apache.camel.component.jetty.JettyHttpProducer.process(JettyHttpProducer.java:75) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99) at org.apache.camel.component.jetty.JettyHttpProducer.process(JettyHttpProducer.java:70) at org.fusesource.fabric.camel.FabricLocatorEndpoint$3.process(FabricLocatorEndpoint.java:111)
Any ideas?
-
-
17. Re: Fabric load balancing endpoint?
wbailey Jun 20, 2012 7:08 AM (in response to davsclaus)Hi,
I've been trying all morning to get this to work but I'm still having problems. Whatever I try doesn't work.
If I remove the jetty endpoint on the client and replace it with a timer like the example code has, then I get different error in the log.
New Client code:
<camelContext trace="false" id="camel" xmlns="http://camel.apache.org/schema/blueprint"> <route id="loadbalancer"> <from uri="timer://foo?fixedRate=true&period=10000"></from> <setBody> <simple>Hello from Zookeeper server</simple> </setBody> <log message="Request received : ${body}"></log> <to uri="fabric:simpleservice"></to> </route> </camelContext>
Error:
Error processing exchange. Exchange[Message: Hello from Zookeeper server]. Caused by: [org.apache.camel.component.http.HttpOperationFailedException - HTTP operation failed invoking http//0.0.0.0:8185/simpleservice with statusCode: 504] org.apache.camel.component.http.HttpOperationFailedException: HTTP operation failed invoking http//0.0.0.0:8185/simpleservice with statusCode: 504 at org.apache.camel.component.jetty.DefaultJettyHttpBinding.populateHttpOperationFailedException(DefaultJettyHttpBinding.java:151)[138:org.apache.camel.camel-jetty:2.9.0.fuse-7-061] at org.apache.camel.component.jetty.DefaultJettyHttpBinding.populateResponse(DefaultJettyHttpBinding.java:61)[138:org.apache.camel.camel-jetty:2.9.0.fuse-7-061] at org.apache.camel.component.jetty.JettyContentExchange.doTaskCompleted(JettyContentExchange.java:182)[138:org.apache.camel.camel-jetty:2.9.0.fuse-7-061] at org.apache.camel.component.jetty.JettyContentExchange.onResponseComplete(JettyContentExchange.java:113)[138:org.apache.camel.camel-jetty:2.9.0.fuse-7-061] at org.eclipse.jetty.client.HttpExchange$Listener.onResponseComplete(HttpExchange.java:1144)[73:org.eclipse.jetty.client:7.5.4.v20111024] at org.eclipse.jetty.client.HttpExchange.setStatus(HttpExchange.java:296)[73:org.eclipse.jetty.client:7.5.4.v20111024] at org.eclipse.jetty.client.HttpConnection$Handler.messageComplete(HttpConnection.java:665)[73:org.eclipse.jetty.client:7.5.4.v20111024] at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:806)[72:org.eclipse.jetty.http:7.5.4.v20111024] at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:218)[72:org.eclipse.jetty.http:7.5.4.v20111024] at org.eclipse.jetty.client.HttpConnection.handle(HttpConnection.java:279)[73:org.eclipse.jetty.client:7.5.4.v20111024] at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586)[71:org.eclipse.jetty.io:7.5.4.v20111024] at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44)[71:org.eclipse.jetty.io:7.5.4.v20111024] at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)[70:org.eclipse.jetty.util:7.5.4.v20111024] at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)[70:org.eclipse.jetty.util:7.5.4.v20111024] at java.lang.Thread.run(Thread.java:662)[:1.6.0_31]
It obivously knows about the endpoint on the server as it's trying to send a request to http//0.0.0.0:8185/simpleservice. However that url doesn't look right to me, should it not be replaced with the actual IP address of the fabric container? and isn't there a ':' missing after http.
Interestingly if I change the camel endpoint in the server to be an ip address rather than 0.0.0.0, then the address in the client changes to be the ip address of the server e.g. http//192.168.10.12:8185/simpleservice.
Any idea when that Jira might be looked into? and has anyone managed to get the example working on Fuse ESB enterprise, as I notice the example code is written for the vanilla Fuse Fabric product?
-
18. Re: Fabric load balancing endpoint?
njiang Jun 20, 2012 10:25 PM (in response to wbailey)Just one small question?
Does the client and server are in the same box?
If not, you may need to specify the real ip address. I don't think the camel-jetty producer can tell the real ip address of "0.0.0.0" so far.
Willem
-
19. Re: Fabric load balancing endpoint?
wbailey Jun 21, 2012 3:34 AM (in response to njiang)Same box, different fabric container.
-
20. Re: Fabric load balancing endpoint?
wbailey Jun 21, 2012 6:31 AM (in response to jrawlings1980)I noticed that Chris updated the Fabric Camel example on github. So I tried the updated example. However I still can't get it to work, I now get the same error:
-06-21 10:00:11,412 | WARN | #2 - timer://foo | TimerConsumer | 161 - org.apache.camel.camel-core - 2.9.0.fuse-7-061 | Error processing exchange. Exchange[Message: Hello from Zookeeper server]. Caused by: [org.apache.camel.component.http.HttpOperationFailedException - HTTP operation failed invoking http//0.0.0.0:8185/fabric with statusCode: 504] org.apache.camel.component.http.HttpOperationFailedException: HTTP operation failed invoking http//0.0.0.0:8185/fabric with statusCode: 504 at org.apache.camel.component.jetty.DefaultJettyHttpBinding.populateHttpOperationFailedException(DefaultJettyHttpBinding.java:151)[138:org.apache.camel.camel-jetty:2.9.0.fuse-7-061] at org.apache.camel.component.jetty.DefaultJettyHttpBinding.populateResponse(DefaultJettyHttpBinding.java:61)[138:org.apache.camel.camel-jetty:2.9.0.fuse-7-061] at org.apache.camel.component.jetty.JettyContentExchange.doTaskCompleted(JettyContentExchange.java:182)[138:org.apache.camel.camel-jetty:2.9.0.fuse-7-061] at org.apache.camel.component.jetty.JettyContentExchange.onResponseComplete(JettyContentExchange.java:113)[138:org.apache.camel.camel-jetty:2.9.0.fuse-7-061] at org.eclipse.jetty.client.HttpExchange$Listener.onResponseComplete(HttpExchange.java:1144)[73:org.eclipse.jetty.client:7.5.4.v20111024] at org.eclipse.jetty.client.HttpExchange.setStatus(HttpExchange.java:296)[73:org.eclipse.jetty.client:7.5.4.v20111024] at org.eclipse.jetty.client.HttpConnection$Handler.messageComplete(HttpConnection.java:665)[73:org.eclipse.jetty.client:7.5.4.v20111024] at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:806)[72:org.eclipse.jetty.http:7.5.4.v20111024] at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:218)[72:org.eclipse.jetty.http:7.5.4.v20111024] at org.eclipse.jetty.client.HttpConnection.handle(HttpConnection.java:279)[73:org.eclipse.jetty.client:7.5.4.v20111024] at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586)[71:org.eclipse.jetty.io:7.5.4.v20111024] at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44)[71:org.eclipse.jetty.io:7.5.4.v20111024] at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)[70:org.eclipse.jetty.util:7.5.4.v20111024] at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)[70:org.eclipse.jetty.util:7.5.4.v20111024] at java.lang.Thread.run(Thread.java:662)[:1.6.0_31]
I did notice that the example creates local instances for the fabric containers, i.e. they end up in a folder called 'instances' inside the fuse installation directory. I was creating containers using a IP address, so they end up in a folder called 'containers' in my home directory in the same box. I tried changing my test to use local containers but still no joy.
I've tried the IP address rather than 0.0.0.0 and that didn't work either. I'm not sure what else to try now. Any ideas?
-
21. Re: Fabric load balancing endpoint?
jrawlings1980 Jun 22, 2012 4:20 AM (in response to wbailey)This thread has gone a different direction from the initial post. I am going to create a new thread to cover Fabric loadbalancing not working.
-
22. Re: Fabric load balancing endpoint?
davsclaus Jun 22, 2012 6:28 AM (in response to jrawlings1980)Yeah good idea
Our team is busy at the moment. But we have a ticket logged about this to look into it.
I just wonder looking at the stacktrace that the hostname: http//0.0.0.0:8185/fabric
Does not have colon to separate the schema, eg ideally it should be
And the 0.0.0.0 the physical ip address.
-
23. Re: Fabric load balancing endpoint?
wbailey Jun 22, 2012 12:22 PM (in response to jrawlings1980)I've finally had some success. I managed to get the updated example to work on a clean install of Fuse esb. Thank you to Chris for updating the example on github.
I then set about modifying the example code in order to replace the timer endpoint with a Jetty endpoint. This didn't work and resulted in the !AbsoluteURI exception shown above being thrown.
I spent a bit of time debugging through the source code and the problem appears to be located in the HttpHelper class of the camel-http component. More specifically in this section of code:
if (!(endpoint.isBridgeEndpoint())) { uri = exchange.getIn().getHeader(Exchange.HTTP_URI, String.class); } if (uri == null) { uri = endpoint.getHttpUri().toASCIIString(); }
The fabric jetty endpoint defined in the example is not a bridgeEndpoint and this meant the above code was executing the first if statement. The result was that the uri is set to the '/simplelbservice' rather than 'http://0.0.0.0:9191/fabric'.
I tried changing the endpoint in the example from:
<from uri="fabric-camel:local:jetty:http://0.0.0.0:{{portNumber}}/fabric"/>
to:
<from uri="fabric-camel:local:jetty:http://0.0.0.0:{{portNumber}}/fabric?bridgeEndpoint=true"/>
However this fails as the fabric component complains it does not understand the bridgeEndpoint parameter. I think that may be a bug because it is a valid jetty endpoint parameter. It throws an exception and will not accept the endpoint.
I've managed to created a workaround by creating my own version of the camel-http jar with a part of the above code removed. With this in place I can use fabric to load balance between multiple containers.
However, as mentioned above it only works when the containers are on the same box, if you try to distribute the containers to other boxes then connection exceptions appear in the log.
-
24. Re: Fabric load balancing endpoint?
njiang Jun 27, 2012 12:01 AM (in response to wbailey)You can remove the message header of Exchange.HTTP_URI if you don't want to install your camel-http bundle.
<camelContext trace="false" id="camel" xmlns="http://camel.apache.org/schema/blueprint"> <route id="loadbalancer"> <from uri="jetty:http://0.0.0.0:8184/simplelbservice"></from> <log message="Request received : ${body}"></log> <removeHeader headerName="CamelHttpUri"></removeHeader> <to uri="fabric:simpleservice"></to> </route> </camelContext>