Chakradhar K
Chakradhar K

Reputation: 509

Camel file input reads same file continuously even with given noop=true

The camel file component is reading the same file continuously and not detecting other files.

I have a camel route as,

<camelContext trace="false" xmlns="http://camel.apache.org/schema/spring">
    <route>
        <from uri="file:C:/Books/input_dir?noop=true"/>
        <dynamicRouter>
            <method ref="fileRouter" method="routeFiles"></method>
        </dynamicRouter>
    </route>
</camelContext>
<bean id="fileRouter" class="org.test.demo.DynamicRouter"/>

and Router as,

public class DynamicRouter {
    public String routeFiles(Exchange exchange){
        final String fileName = (String) exchange.getIn().getHeader(Exchange.FILE_NAME_ONLY);
        System.out.println("FILENAME: "+fileName);
        if(fileName.contains("survival")){
            return "file:C:/Books/output_dir";
        }else {
            return "file:C:/Books/target_dir";
        }
    }
} 

Whenever a file say beahomelist is dropped into C:/Books/input_dir folder it reads the first file and never stops as the log below

FILENAME: beahomelist FILENAME: beahomelist FILENAME: beahomelist FILENAME: beahomelist FILENAME: beahomelist FILENAME: beahomelist FILENAME: beahomelist FILENAME: beahomelist....

and doest not detect any further files put in the same folder. Even though noop=true is given it happens so. Please provide some suggestions on this. I am using camel version: 2.13.0

Upvotes: 1

Views: 4231

Answers (1)

Claus Ibsen
Claus Ibsen

Reputation: 55545

Read the documentation about dynamic router eip, see that Beware! box in the top

Though it looks like you should use "dynamic to" instead of dynamic router, see this FAQ

So just use

  <recipientList>
        <method ref="fileRouter" method="routeFiles"></method>
    </recipientList>

Upvotes: 1

Related Questions