I'm new at using play framework and I need to have a piece of code running everyday without effecting request/response cycle of play! I did this in Job
class of play and the Job
running time is little more than half hour. After running my play app, then I recognized that while Job
is running play doesn't accept any request. The methods in my controller responds after Job
finish its task. So it means it is blocking them. I am waiting for your advice.
import parser.Parser;
import parser.ProductModel;
import play.jobs.Every;
import play.jobs.Job;
import play.jobs.OnApplicationStart;
@OnApplicationStart
@Every("24h")
public class ParserJob extends Job {
//private Parser parser=new Parser();
@Override
public void doJob() throws Exception {
Parser parser=new Parser();
long start=System.currentTimeMillis();
parser.firsatBuFirsat("http://www.firsatbufirsat.com/");
long finish = System.currentTimeMillis();
System.out.println("TIME : "+(finish-start)/1000);
}
}
Change @OnApplicationStart
to OnApplicationStart(async = true)