Ideally we should define post read strategy for already read files to move those into different location or archive.
But still If you have manual strategy based on time definition then if I remember correctly, there is option in file adapter polling configuration wizard to filter out files based on age(we can define that do not read a file if it is older than specified time duration). I call this manual strategy because if you do this then you will have to make sure that combination of timings to put new file in folder and polling frequency of adapter is synchronized accordingly with the age parameter you define here.
Just explore on that direction if it is helpful.
Ok, I see where I was going wrong with this. I was talking about "Min File Age" parameter but your usecase requires something like "Max File Age" parameter. I think it is currently not there but it looks interesting option if oracle want to look into it.
For now, I can think of 1 way for your usecase. Please follow lead below:
- Create File read adapter but do not read content. It will just read all the metadata of your files one by one and will instantiate state of process/thread with it.
- In your process or proxy, have an if-else where you will check LastModifiedTimestamp meta data retrieved from file adapter and will check that it should be less than your defined time limit.
- It it fits your criteria then do a sync file read and pass the parameter for filename and directories from input file adapter to read content of the file and do further processing. else do nothing.
- After invoking sync file adapter(since it is outbound), you will receive file content in output of invocation and you can processs it further as per your need in rest of the pipeline/process.
Below is a good blog which implements something similar. Of-course not exactly same but all you have to do is tweak configuration mentioned below little bit to change conditions as per your need.
Apart from the payload, Oracle File Adapter publishes the following header metadata, from the inbound service, as shown in Figure 4-24:
jca.file.FileName: file name
jca.file.Directory: directory name
jca.file.Batch: a unique name for a batch in case of debatching
jca.file.BatchIndex: the batch index for each message within the batch for debatching
jca.file.Size: the file size
jca.file.LastModifiedTime: the last modified time for the file
Capture the jca.file.LastModifiedTime compare it with whatever time is required. If jca.file.LastModifiedTime < 10:00 AM then do not action, else perform the action.
do you kno hat the value means in the example:
what should I rite for read only the files that are only neer then yesterday?
I guess this is the date format in java, date.getTime() method in java returns a long value. For example if the file modified time is "Jul 27, 2014 5:53 PM"; then the value returned in soa composite is 1406501580000. This value is same as java value returned by the following java code:-
String dateString = "Jul 27, 2014 5:53 PM";
DateFormat format =
Date date1 = format.parse(dateString);