J2EE File Event Pattern  
Author Message
jeff.harman





PostPosted: 2006-7-10 22:56:00 Top

java-programmer, J2EE File Event Pattern I have a design issue that I was hoping that this list could assist me
with:

I need to create a File Event Handler that is J2EE compliant.

The basic requirements are:
- Detect the arrival of a file on a particular path (including
file masking patterns)
- Recognize the type of file
- Route either data stream or file reference to an appropriate
handler. The handler will process the contents of the file.
- Election of an instance to handle the file (the file will
arrive on a shared drive that all instances of the app will see) to
prevent multiple instances of the same file being processed

Anyone have any good pointers or patterns to use?

Thanks,
Jeff Harman

 
pranshu





PostPosted: 2006-7-10 23:58:00 Top

java-programmer >> J2EE File Event Pattern Hello Jeff,

The multiple instance part is interesting.

One option is to use a clustered scheuler.
I have used flux, and it works well.

I think open source Quartz does the trick as well.
http://www.opensymphony.com/quartz/wikidocs/ConfigJDBCJobStoreClustering.html

Alternatively, you could schedule this job on all machine and try to
implement concurrency control which works across JVMs.

The lock - for handling concurrency - is best obtained from a database.
Alternatively, you can make your life more complex and use a file
system and custom code to keep this lock, but be aware that you will
need to check that the OS you are using allows file locking. Java.NIO
lock may not work across JVMs.

Java is quite efficient at listing the files in the file system, so you
are unlikely to run into any issues while polling.

If you have a clustered database - it might be better to create this
job on the database- or trigger it from database - so that it runs only
on one machine and fails over whenever the database does.


Pranshu

email***@***.com wrote:
> I have a design issue that I was hoping that this list could assist me
> with:
>
> I need to create a File Event Handler that is J2EE compliant.
>
> The basic requirements are:
> - Detect the arrival of a file on a particular path (including
> file masking patterns)
> - Recognize the type of file
> - Route either data stream or file reference to an appropriate
> handler. The handler will process the contents of the file.
> - Election of an instance to handle the file (the file will
> arrive on a shared drive that all instances of the app will see) to
> prevent multiple instances of the same file being processed
>
> Anyone have any good pointers or patterns to use?
>
> Thanks,
> Jeff Harman