I am implementing org.quartz.Job interface from the Quartz API version 1.4.
I have an execute method which follows the following steps:
1) Create arraylist of names of the unread files in an FTP folder
2) for the list
a) process 50 files at a time , each creating a response .. save the responses in a map .. rename file as read
b) save all these responses as files on FTP
The problem is, when the number of files is large (in the order of 1000-1500) step 2a) and 2b) get intermingled... i observe when i write loggers and console messages.
Here .. the number of response files generated decreases, as the order of processing is twisted.
I suspect there is some multithreading involved... i observe some at eclipse debugger as well.
I tried keeping step 1 and 2 in a synchronized block.. and the correct number of responses were found.
But I still doubt the order of execution ( on observing the logger ).
Is this scheduler multithreaded .. if yes, how does it affect the code in execute method ? and is my apporach correct ??
Please help... I am also looking for some documentation.. will update if I get something useful.
Anrd
"One of the best things you could do is to simplify a larger application into a smaller one by reducing its process and complexity - Fowler"
Hmm, I'm not really clear on how you've set up your scheduled jobs. Do you have a job for retrieving files and a separate job for putting back responses?
As you said, you have as single job for processing files and saving the response, then check out if you mistakenly created multiple Jobs for the same or not.
First of all apoligies for the delay in response..
Martijn , The probelm is 2a gets processed but 2b is skipped.
i have declared the execute method synchronized to synchronize the process.
And i have chenged the processing method to one request file at a time. Now the process goes like this :
1. Read a request file
2. Process this file ( this consumes some time ) : response is generated here
3. Put response on FTP
The magnitude of the problem has reduced , but it still exists.
The code follows:
Anrd
"One of the best things you could do is to simplify a larger application into a smaller one by reducing its process and complexity - Fowler"
I think I'm still unclear. From reading your code it looks like:
1.) The scheduler will call execute on the Job (how often are you calling this BTW?)
2.) It goes a gets a list of files from the FTP server.
3.) For each valid file it generates a response and puts that back on the FTP server.
You say that the putting back of the response is 'skipped', how so? What logging etc are you seeing? Is the method not being called at all?