2 Replies Latest reply on Feb 8, 2011 9:14 PM by njiang

    Jetty:http endpoint issue

    woggle23

      Evening

       

      I'm having issues consuming from a Jetty:http endpoint, I've attempted to use the camel-jetty component to create a simple route as follows:

       

      context.addRoutes(new RouteBuilder() {

       

                  public void configure() {

                from("jetty:http://localhost:8080").process(new Processor() {

                              public void process(Exchange e) {

                              System.out.println("HTTP REQUEST Received" );

                          }

                      });

                  }

              });

       

      I've launched a server, using the jetty-server from eclipse.org, as follows:

       

      Server server = new Server(8080);

      server.start();

       

      When running the above and entering "http://localhost:8080" into a browser I expected to see "HTTP REQUEST Received". Unfortunately I didn't.

       

      I commented out the above route and added a handler to the server which displayed a simple webpage when "http://localhost:8080" is entered into a browser. When uncommenting the above route the webpage stopped working.

       

      Any ideas what I'm doing wrong here?

       

      Many thanks for your help in advance.

       

      Matt

        • 1. Re: Jetty:http endpoint issue
          davsclaus

          You end up with 2 jetty servers.

           

          When you do

          from(jetty) in a Camel route, then that becomes the server.

           

          So instead dont start the Jetty server, but only Camel.

          And then from a web browser hit that url

           

           

          On the other hand if you want Camel to call an external http service, then you should use the http component.

          • 2. Re: Jetty:http endpoint issue
            njiang

            camel-jetty consumer will start a new Jetty server when the consumer is stared.

            If you want to leverage a web container to manager the http services, you may consider to use the camel-servlet component.

             

            Willem