mongodb - Spring Batch reader file by file -


i'm developing spring webapp, using spring boot , spring batch frameworks.

we have set of complex & different json files, , need to:

  1. read each file
  2. slightly modify content
  3. finally store them in mongodb.

the question: makes sense use spring batch task? can see in tutorials examples etc, spring batch right tool line line processing, file file?

i don't have problems writer (mongoitemwritter) , processer, not see how implement reader.

thanks!

yes can definetly use spring batch. item reader can file.

 public class customitemreader implements initializingbean{      private list<file> yourfiles= null;      public file read() {         if ((yourfiles!= null) && (yourfiles.size() != 0)) {             return yourfiles.remove(0);         }         return null;     }      //reading items service     private void reloaditems() {         this.youritems= new arraylist<file>();        // populate items      }       @override     public void afterpropertiesset() throws exception {         reloaditems();     } } 

a custom processor :

public class myprocessor implements itemprocessor<file, file> { @override public file process(file arg0) throws exception {    // apply logic file before transferring writer  return arg0;  } } 

and custom writer :

  public class mywriter{       public void write(file file) throws ioexception {          }    } 

Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -