יום ראשון, 11 במאי 2014

Using Jetty and Camel

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:

<groupId>org.apache.camel</groupId>
	<artifactId>camel-jetty</artifactId>
	<version>2.12.1</version>
Note: All the Camel compoenents version must match otherwise linkage between components problems may raise.
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 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);
     
        // send a html response
        exchange.getOut().setBody("<html><body><H3>Hello Mazal Saadon</H3></body></html>");
    }
}

Executing the sample result:


Capture59
Resources:
http://camel.apache.org/jetty.html

אין תגובות:

הוסף רשומת תגובה