0 Replies Latest reply on Sep 27, 2012 2:56 AM by ddelizia

    Route consuming the sme file does not start the second time that it is ran

    ddelizia

      Hi all,

      I need to consume a file (always the same) when an http request is done. Basically what I have to do is when an http request is done on a given address then I have to consume a file on an ftp, and process it.

      So I created the route as follow:

       

           from(

                  "jetty:http://0.0.0.0:" + jettyPort + "/"

                          + jettyControllerPathFeed).process(new Processor() {

       

              @Override

              public void process(Exchange arg0) throws Exception {

                  getContext().startRoute(AdobeS7DefaultRoute.ROUTE_INCREMENTAL);

              }

          });

       

           from(

                  "file:/opt/servicemix/data/smx-data/outbox?fileName=test.jtl&noop=true&idempotent=false").noAutoStartup()

                  .id(ROUTE_INCREMENTAL)

                  .to("direct:" + ROUTE_INCREMENTAL)

                  .process(new Processor() {

                      @Override

                      public void process(Exchange arg0) throws Exception {

                          getContext().getShutdownStrategy().setTimeout(1);

                          getContext().stopRoute(ROUTE_INCREMENTAL);

                      }

                  });

                   

          from("direct:" + ROUTE_INCREMENTAL)

                  .unmarshal(csv)

                  .process(new Processor() {

                   

                  //do things

                  })

                  .split(xpath(splitXml))

                  .to("jms:" + jmsincrementalQueue + "?jmsMessageType=Text");

                   

      The problem I get running these routes on the esb is that the route ROUTE_INCREMENTAL run correctly just the first time when I do the request the second time the route with id ROUTE_INCREMENTAL is not started. Debugging the route the second time I do the http request, the line

      getContext().startRoute(AdobeS7DefaultRoute.ROUTE_INCREMENTAL);

       

      seems to not work.

       

      I also used

      noop=true&idempotent=false

       

      to deactivate the idempotentrepository.

       

      I also tried to use a filebased Idempotent adding to my route:

      .idempotentConsumer(simple("$"), FileIdempotentRepository.fileIdempotentRepository(new File("/opt/file.txt")))

       

      in this case I use the date as id, so the second time I do the request the Id should be different from the firstone. But even in this case the route is not started from the processor of the first route during the second request.

       

      Any Idea what is going on? why the first time the routes work perfectly and the second time the route ROUTE_INCREMENTAL is not started?

      There is any better solution to do what I would like to do?

       

      Thanks in advance for your help

      Danilo