You can use the Jetty component to setup a HTTP server in Camel.
And then route that to the AMQ queue
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.
Thats just whatever you wanna call it. In you case you may want it as:
So there is no context path at all.
That means a client can hit the url: http:localhost and access the jetty server.
I get following error. Can somebody help
HTTP ERROR: 404
Problem accessing /. Reason:
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 K
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
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
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
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?
is this correct? when we fetch data from queue it comes as an object right? how do decode the value alone?
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.
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.
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");
context is the CamelContext which is essential Camel.
If you use a Processor then you can access it from the exchange parameter
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 :
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)