I wants to switch from Tomcat to jetty in my Camel CFXRS sample .
The first stage is a basic test of the combination of Jetty and Camel.
Add to the pom:
Note: All the Camel compoenents version must match otherwise linkage between components problems may raise.<groupId>org.apache.camel</groupId><artifactId>camel-jetty</artifactId><version>2.12.1</version>
Add a very simple Route :
public void configure() {from("jetty:http://localhost:8080/SayHello").process(new ReplaySimpleHtml());
The request – replay processor:
public class ReplaySimpleHtml implements Processor {public void process(Exchange exchange) throws Exception {// just get the body as a stringString body = exchange.getIn().getBody(String.class);// we have access to the HttpServletRequest here and we can grab it if we need itHttpServletRequest req = exchange.getIn().getBody(HttpServletRequest.class);// send a html responseexchange.getOut().setBody("<html><body><H3>Hello Mazal Saadon</H3></body></html>");}}
Executing the sample result:
Resources:
http://camel.apache.org/jetty.html
אין תגובות:
הוסף רשומת תגובה