On Thu, Sep 27, 2012 at 10:23 AM, ddelizia <danilo.deli...@unic.com> wrote:
> 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("${date:now:yyMMddHHmmssZ}"),
> 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
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Route-consuming-the-same-file-does-not-start-the-second-time-that-it-is-ran-tp5720095.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Whoa that was way overkill and complicated.

If you need to pickup a file then just either use the content enricher
EIP (in your case it would be pollEnrich)
http://camel.apache.org/content-enricher.html

But it could be as simple as a message translator eip
http://camel.apache.org/message-translator.html

eg to transform the message to a java.io.File with the file name.

from("jetty")
   .transform().simple("/opt/servicemix/data/smx-data/outbox/test.jtl",
File.class)


-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cib...@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Reply via email to