-
1. Re: Problem in getting browser values through camel
davsclaus Feb 7, 2011 6:46 AM (in response to praga)You can use the Jetty component to setup a HTTP server in Camel.
And then route that to the AMQ queue
from("jetty:0.0.0.0:9080/myserver/mypath") .to("activemq:queue:foo")
-
2. Re: Problem in getting browser values through camel
praga Feb 7, 2011 6:50 AM (in response to davsclaus)Hi,
Thanks for your reply... what does myserver/mypath ?? refers to?
if you have any examples on this regard can you kindly share, it would really be helpful and kind of you.
Thanks in advance.
-
3. Re: Problem in getting browser values through camel
davsclaus Feb 7, 2011 9:35 AM (in response to praga)Thats just whatever you wanna call it. In you case you may want it as:
from("jetty:0.0.0.0:80").to("activemq:queue:foo);
So there is no context path at all.
That means a client can hit the url: http:localhost and access the jetty server.
-
4. Re: Problem in getting browser values through camel
praga Feb 9, 2011 6:32 AM (in response to davsclaus)Hi,
I get following error. Can somebody help
HTTP ERROR: 404
Problem accessing /. Reason:
NOT_FOUND
-
Powered by Jetty://
PFA of my project zip file. Kindly let me know where iam going wrong. Iam just trying to get browser values and print in the method "MyBookService". If this part is working fine I can easily write it into queue.
-
HHTPtoJMSInFuse.zip 19.8 KB
-
-
5. Re: Problem in getting browser values through camel
davsclaus Feb 9, 2011 10:05 AM (in response to praga)You can try with a context path, like foo
from("jetty:0.0.0.0:80/foo")...
Then hit the url from the webbrowser: http://localhost/foo?something=someValue
-
6. Re: Problem in getting browser values through camel
praga Feb 10, 2011 3:05 AM (in response to davsclaus)Hi,
When I start the bundle , the routebuilder starts automatically and the "from" gets executed even before i invoke the browser. What should be done in such a situation?
starting of the bundle automatically invoke the flow and gives no time to invoke the browser and throws error
-
7. Re: Problem in getting browser values through camel
davsclaus Feb 10, 2011 5:34 AM (in response to praga)What do you mean? Which error do you see?
When the bundle start it start the Camel route (eg the from). In the from you use Jetty which is a HTTP Server.
Just like any other HTTP server on the internet, eg http://www.google.com. So clients can "talk to it" using HTTP from a web browser by its url.
Edited by: davsclaus on Feb 10, 2011 10:33 AM
-
8. Re: Problem in getting browser values through camel
praga Feb 10, 2011 7:03 AM (in response to davsclaus)Hi,
Thanks . Iam able to print back to the browser. Actually jetty component feature has not be installed properly in the fuse server. i installed the feature already. but when i listed features:list camel-jetty showed uninstalled. now i installed and it is working fine now. thanks a lot
-
9. Re: Problem in getting browser values through camel
praga Feb 10, 2011 9:13 AM (in response to praga)Hi,
One more clarification pleaseeeeeeeee. now what i have done is give input value in browser and the value is now stored in queue. that is from http to queue.
Now i need to get the values back from the queue and post it in the browser.
that is from queue endpoint to jetty:http endpoint. is that possible? if yes how?
from("jms:queue:HTTPQueue")
.process(new MyBookService())
.to("jetty:http://localhost:8080/HHTPtoJMSInFuse");
is this correct? when we fetch data from queue it comes as an object right? how do decode the value alone?
-
10. Re: Problem in getting browser values through camel
davsclaus Feb 10, 2011 10:21 AM (in response to praga)No thats not doable.
HTTP is request/response, so when a client hit the url from a webbrowser, that webbrowser sends a request and waits for the response.
So when you receive the request from jetty in the Camel route, you must process the request, and set a message which is used as reply. Camel will send back the reply to the web browser, with whatever the message contains at the end of the route.
So during that routing you need to grab that message from the queue and put it into the camel message.
For that you can use the Content Enricher EIP pattern. Or the Polling Consumer EIP.
http://camel.apache.org/content-enricher.html
http://camel.apache.org/polling-consumer.html
When you grab the message from the queue, you have to consider what to do if there is no message. And also do you need to use message selector or some sort to select the desired message from the queue in case there are more messages.
Those EIP patterns support a timeout, so you can wait a bit in case the message is late. You can also use noWait to just check if there is a message asap, and not wait if there is not.
-
11. Re: Problem in getting browser values through camel
praga Feb 11, 2011 1:55 AM (in response to davsclaus)Hi,
iam trying with polling consumer. But where is the context declared? Is it a object of camelcontext? how should it be declared? I get a error saying context cannot be resolved.
Endpoint endpoint = context.getEndpoint("activemq:my.queue");
-
12. Re: Problem in getting browser values through camel
davsclaus Feb 11, 2011 8:21 AM (in response to praga)context is the CamelContext which is essential Camel.
If you use a Processor then you can access it from the exchange parameter
-
13. Re: Problem in getting browser values through camel
davsclaus Feb 11, 2011 8:22 AM (in response to praga)If you want to get the hands on how to developer with Camel and ActiveMQ, then you can consider the virtual trainings
-
14. Re: Problem in getting browser values through camel
praga Feb 14, 2011 2:01 AM (in response to davsclaus)Hi,
Thanks a lot for that reply. I tried using polling consumer
CamelContext context = new DefaultCamelContext();
Endpoint endpoint = context.getEndpoint("jms:queue:HTTPQueue");
PollingConsumer consumer = endpoint.createPollingConsumer();
exchange = consumer.receive();
My router has :
from("jetty:http://localhost:8080/HHTPtoJMSInFuse?name=praga")
.inOnly("jms:queue:HTTPQueue")
.process(new MyBookService())
;
When i try to run the bundle in browser i get the following error
org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: jms://queue:HTTPQueue due to: No component found with scheme: jms at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:398)
at com.nokia.fuse.http.MyBookService.process(MyBookService.java:33)
at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:50)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)