Uw betrouwbare partner voor (mobiele) web applicaties
TwitterEmailRSS

Asynchronous jobs with Play Framework

Ever needed to run some standalone asynchronous job from Java and found it to be a bit tedious? Read on..

Declaring a Job in Play that runs every 3 seconds  and increments a property is as simple as this:

@Every("3s")
public class PublishJob extends Job {

  private int i;

  @Override
  public void doJob() throws Exception {
    i++;
  }
}

Q: W00t! It can’t be that simple!
A: Sorry, it really is.