MuleESB / Apache Camel Interview Questions
How does the Camel File component work for polling and processing files?
The camel-file component polls a directory for new files and processes each one as a Camel Exchange. The file body defaults to a java.io.File or InputStream depending on configuration. After processing, the file can be moved, deleted, or left in place based on the move, delete, and noop options.
// Poll, process, and move to done/ on success:
from("file:/data/in?move=done&moveFailed=failed&readLock=changed")
.log("Processing: ${header.CamelFileName}")
.unmarshal().csv()
.split(body())
.to("jms:queue:order-items")
.end();
// Write a file from a route:
from("direct:writeReport")
.setHeader(Exchange.FILE_NAME, simple("report-${date:now:yyyyMMdd}.csv"))
.to("file:/data/out");Key file component options: noop=true (leave file; for testing), delete=true (delete after read), move=dirname (move to subdirectory), readLock=changed (wait until file stops growing), delay=ms (polling interval), include=regex (file name filter), sortBy=filename (processing order). The component sets the CamelFileName and CamelFileLastModified headers automatically.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
