|
Jetty has been edited by Claus Ibsen (Aug 10, 2008). Change summary: CAMEL-628 Jetty ComponentThe jetty: component provides HTTP based endpoints for consuming HTTP requests that arrive at an http endpoint. URI formatjetty:http:hostname[:port][/resourceUri][?options]
UsageYou can only consume from endpoints generated by the Jetty component. Therefore it should only be used as input into your camel Routes. To issue HTTP requests against other HTTP endpoints you can use the HTTP Component SampleIn this sample we define a route where we expose a http service at http://localhost:8080/myapp/myservice from("jetty:http://localhost:8080/myapp/myservice").process(new MyBookService());
Our business logic is implemented in our MyBookService class where we can access the http request stuff and return a response. public class MyBookService implements Processor { public void process(Exchange exchange) throws Exception { // just get the body as a string String body = exchange.getIn().getBody(String.class); // we have access to the HttpServletRequest here and we can grab it if we need it HttpServletRequest req = exchange.getIn().getBody(HttpServletRequest.class); assertNotNull(req); // for unit testing assertEquals("bookid=123", body); // send a html response exchange.getOut(true).setBody("<html><body>Book 123 is Camel in Action</body></html>"); } } See Also |
Unsubscribe or edit your notifications preferences
