0
votes

I created a job batch to extract data from csv file to a jdbc using filejdbc module, it worked properly, but when I scheduled the batch to run every 5 minutes, it did not work with the incremental load concept, it loaded all the data again, Is there any feature to schedule the batch with incremental load?

Is the solution to run the batch once, and to create a stream to do the incremental load? Will the stream load all the data again, or it will just continue from a certain point.

Please explain how can I achieve the incremental load concept using spring XD?

Thanks, Moha.

1
What version of XD are you using? A stream definition would also be helpful. - Michael Minella
I am using Spring xd 1.2 - Mohammad Abu Shaera
Can you add your stream definition to your question? - Michael Minella
the jdbc as a source is not defined to be incremental, and non of its parameters allow me to do incremental imports. SO THE STREAM OPTION IS NOT VALID HERE. - Mohammad Abu Shaera
We still call the job definition a "stream definition". Sorry for not being precise, but the definition of your job is required to be able to see what's wrong with the incremental load for your job. - Michael Minella

1 Answers

0
votes

I suppose what is missing is the concept of 'state'...the filejdbc module does not seem to know where the last import stopped. I do something similar but I use a custom batch job and I use a meta store to keep track of where the last load stopped - that is where the next incremental will pick up from, etc.

Since you're using a module that came with spring-xd itself, you may not have this flexibility but you may have to options:

a- your destination table can define unique fields that will prevent duplicates. That way, even if its trying to load ALL the data again, only new rows will get inserted. This assumes that the module is using 'insert ignore' (or something similar and not just basic insert (which will throw an error/exception). This, I must say, will end up being non-optimal pretty quickly, pretty soon.

b- If its an option, write a module that can delete the file after its uploaded into the db. You can construct a complex stream that will first do your data load and then file delete.