Reputation: 223
How to define a Camel Route with an HTTP for the "from" endpoint?
My goal is to define a Route that when there is an HTTP request, a Message will be enqueued on the ActiveMQ Queue.
I tried the following Route definition:
<route>
<from uri="http://localhost:8181/cxf/crm/customerservice/customers" />
<to uri="activemq:queue:LOG.ME" />
</route>
From a browser, I access the URL:
http://localhost:8181/cxf/crm/customerservice/customers/123
I had verified that the HTTP request had reach the web service "customerservice", since I received an XML response from the web service. However, no Message was enqueued on the ActiveMQ Queue.
Below is the Route definition that processes Messages from the ActiveMQ Queue.
<route>
<from uri="activemq:queue:LOG.ME" />
<multicast>
<pipeline>
<bean ref="processor1" method="handle" />
<to uri="mock:result" />
</pipeline>
<pipeline>
<bean ref="processor2" method="handle" />
<to uri="mock:result" />
</pipeline>
</multicast>
</route>
I verified that nothing was enqueued to the ActiveMQ, because the "handle" method of my beans "processor1" and "processor2" was not executed.
How to define a Camel Route with an HTTP for the "from" endpoint?
Thanks.
Upvotes: 2
Views: 5574
Reputation: 4877
To listen to incoming http requests a proxy can be set up using jetty or cxf component which will then invoke the web service as well as log a message to activemq.
For example,
from("jetty:http://localhost:8282/xxx").
to("http://localhost:8181/cxf/crm/customerservice/customers").
to("activemq:queue:LOG.ME");
Now, to access the web service the proxy can be invoked as http://localhost:8282/xxx
, instead of directly calling the web service. A proxy can be set up using the cxf component too, it is well documented.
Upvotes: 2
Reputation: 22279
If you want to listen to HTTP requests, then you need either to use the servlet component if you are running inside a web application or the jetty component which embedds a simple http server.
Both have good documentations and examples.
The http and http4 components are for producers only (<to ... />
).
Upvotes: 3