On Thu, Nov 1, 2012 at 4:55 AM, demetrios <[email protected]> wrote: > Hi All > I am new to camel and currently have an issue with a fileConsumer I have > built. > > I am using camel to read in a message file via a route. As part of this I > am using the body received in this file to read to acquire a file location > defined in the body. I then want camel to take this value and read in a > new body from another file. > > Here is what my consumer routine looks like: > > public void hello(@Header("Camel.File") String filePath, @Body String > body, Exchange exchange){ > int lastSlash = > filePath.lastIndexOf(System.getProperty("file.separator")); > String path = filePath.substring(0, lastSlash); > String fileName = filePath.substring(1+lastSlash); > Exchange newExchange = > consumerTemplate.receive("file:"+path+"?fileName="+fileName) > exchange.getIn().setBody(newExchange.getIn().getBody()); > > } > > This works fine one the first run for a particular file however if I want to > reprocess that message in the same instance to the same file, the call : > consumerTemplate.receive("file:"+path+"?fileName="+fileName) > hangs. >
Read the Java doc of this class and its methods. And understand the difference between receive / receiveNoWait / and the last variation with a timeout. And then learn that the file consumer by default moves the file after its been processed to a .move sub dir. You can configure this, or even enable noop=true. And if you just want to get a hold of the file and no need to move/delete etc it afterwards. You can just store the java.io.File reference in the message body. Then you don't need to use the consumer template. Still you need to deal with - what should I do if the file does not exists. > I have debugged into the receive call and it seems that the file read in > earlier is still locked by the previous run. > > Does anyone have any ideas on what I am missing here? > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/consumerTemplate-receive-function-on-same-file-hanging-tp5721925.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen ----------------- Red Hat, Inc. FuseSource is now part of Red Hat Email: [email protected] Web: http://fusesource.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen
