I am interested in hearing opinions from experienced developers on which represents best practice in the following scenario:

When files appear in a filesystem, processing needs to occur. Meta data about the files also exists in a database. Which is better: 1) to monitor the file system directly for new work, then query the database for meta data needed in processing or 2) to monitor the database for new work and then inspect the filesystem to pick the file to work on?

I am an experienced architect myself and this is a real-world problem at a client. I have an opinion, but I'm interested in hearing arguments for both sides that will help me refine my opinion and/or better defend my recommendation to the client.

If you've worked with a similar situation or otherwise have an opinion on best practice in this scenario, please share your thoughts!


Couple things that seem unclear, that could affect the choice.

1. How did the meta data get there in the database if its a new file?

2. When you say "process file", does that mean you have application code or sql code that does this processing?

3. Is the processing of the files heavily intensive or quickly done?

I'd go for monitoring for new files. This can be done by creating an app that hooks into windows. This means you won't have to create a polling mechanism (either for files or for new database entries).