0 Replies Latest reply on Oct 1, 2014 6:36 AM by Jackson Kaloli

    Apache-camel routing to remote http endpoint

    Jackson Kaloli Newbie

      I am quite new in apache camel and have been developing a test project to route some message to an http server that is running on my machine-although for production purposes this will be in a different machine. Now when I post messages through telnet to that server it works fine but when I route through camel I get the error failed to initialize connection, server disconnected. my code is below. Can someone tell me whether it is an issue with my routing or it is the message format that camel is sending out. I am using camel 2.13.2 as a standalone. Thanks

       

       

      public class MyRouteBuilder extends RouteBuilder {

          public void GetResponse() {
              System.out.println("Writing to server...");
              CamelContext context = new DefaultCamelContext();

              final String msg = "SECTOR,GCS/I,JKAB016/123123,222,DESCRIPTION::=\"camel sector\",SHORT.NAME::=\"integration\"";
              try {
                  context.addRoutes(new RouteBuilder() {
                      @Override
                      public void configure() {
                          from("file://src/data/test").convertBodyTo(String.class).to("http://127.0.0.1:7023");
                      }
                  });

                  ProducerTemplate template = context.createProducerTemplate();
                  context.start();
                 
                  template.sendBody("file://src/data/test", msg);

                  Thread.sleep(1000);
                  context.stop();
              } catch (Exception e) {
                  e.printStackTrace();
              }

          }