java - How to notify when a Camel seda queue is complete? -


the use case have zip file containing many csv files. each line in each file sent seda queue processing. problem i'm having i'd know when every line has been processed seda queue perform other work. i'm not sure how approach this. currently, i'm investigating using polling test when seda queue empty, produce false results if lines processed faster arrive.

code

i have class unzips zip file , reads each file inputstream. each line in file sent producer in turn sent seda queue.

@component public class csvprocessor {      @resource(name = "csvlineproducer")     producertemplate producer;      public void process(inputstream flatfilestream) throws ioexception {         if (flatfilestream==null) return;          try {             lineiterator = ioutils.lineiterator(flatfilestream, "utf-8");             while (it.hasnext()) {                 final string recordline = it.nextline();                 this.producer.send(new processor() {                     public void process(exchange outexchange) {                         outexchange.getin().setbody(recordline);                     }                 });             }         } {             ioutils.closequietly(flatfilestream);         }     } } 

here camel config.

<camelcontext xmlns="http://camel.apache.org/schema/spring" trace="true">     <template id="csvlineproducer" defaultendpoint="seda:flatrecordstream"/>      ...      <route>         <from uri="seda:flatrecordstream" />         <bean ref="myprocessor" method="processline" />     </route>      ...  </camelcontext> 


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -