简体   繁体   中英

How to listen file modifications in spring-camel?

I am novice in spring-camel and apache camel overall
I've read http://camel.apache.org/file.html
and I want to listen file modifications.

Thus I wrote:

@PostConstruct
public void init() {
    from("file:feed.txt")
            .log("msg: ${body}")
            .process(exchange -> {
                System.out.println(exchange.getIn().getBody());
            });
}

init method is invoked on startup but process callback is not invoked.

I tried to add new lines into the file after startup but nothing happens.
Also I am sure that application sees the file because it logs on startup:

2017-10-24 15:26:13.421  INFO 10620 --- [           main] o.a.camel.spring.SpringCamelContext      : Route: route1 started and consuming from: file://feed.txt

What do I wrong?

Thanks Oleg Kurbatov

The correct link:

http://people.apache.org/~dkulp/camel/file2.html

I created directory feed instead of file feed.txt

and put several files there. Then I started app and Camel read it, Camel moved my files into .camel directory. Also tried to put file dinamycally. I put file into feed folder and Camel read it successfully.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM