0
votes

I have two file, one file contain images of scan documents saved in single X.img file and other is meta data file saved as X.xml which contain image length and image data offset and other data related to document.

Now I have to first read xml file and get image length and offset value from where to read image from img file. Since xml file is data file have small in size but my image file are large in size.

I am using camel for consuming files from remote server and need to process only if respective xml and img file available. Xml file and img file will have same name e.g. If my xml file is 27092018.xml then respective image file name is 27092018.img

How I can achieve this using camel ftp?

1
Hi! If you look at the "doneFileName" parameter in the Camel File component documentation here camel.apache.org/file2.html (FTP component is derived from File) you can probably use the .xml file as the "done file" and only consume .img files that have a matching .xml file. - Screwtape

1 Answers

0
votes

There are several ways you can do this. I would suggest you look at the Claim Check EIP which will help you achieve this.

In short the following steps will need to happen.

  1. Read the XML file and store the relevant information in some sort of persistent storage such as a database table,NoSQL object or a cache like Hazelcast/DataGrid. The data would be the xml file name and the image ofset, size and other informaiton like you mentioned. The XML file name(27092018.xml) can be used as the key if it is unique. This is the claim check you are storing in the database.
  2. Later when you read the XML file you can use this name with a Data Enricher to get the claim check out of the database and process the image file.Essentially you us ethe file name to look up the information in the database.

See this Wiki for more information around this pattern.