J2EE File Event Pattern

J

jeff.harman

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
 
P

pranshu

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top