Hi Camel users I have a route that consumes big XML files (100 to 300 MB), splits them into chunks and processes the chunks. from(pollingFileConsumer) .routeId("bigFileConsumer") // here I would like to make a very basic check if the file looks as expected .split().tokenizeXML("XmlElementNameToSplitWith").streaming() // Continue to work with file chunk from splitter .bean(whatever)
Before the splitter, I would like to check if the file is in expected format. To avoid reading the whole big file (memory), I would like to read the first 2000 chars (no matter if XML is invalid) and look up some required specifics (for example with regex) like the namespace. What is best practice to do this? I could of course implement a bean and call it. But the message body is "java.io.File". => When I convert it into a String (implicitly by annotate the method with "@Body String body" this converts the whole big file. => When I read the File through a stream, I would probably have to reset the Stream so that Camel can read the File from beginning. Thanks for suggestions Stephan