Launch any method of your models via a TaskQueue.
package models;
import models.deferer.ModelTaskInvoker;
public class MyModel extends Model {
@Idpublic Long id;
public static MyModel findById(Long id) {
return Model.all(MyModel.class).filter(“id”, id).get();
}
public void myMethod(String param1, Int param2, etc..) {
// execute some application logic here …
}
public void deferMyMethod(String param1, Int param2, etc..) {
ModelTaskInvoker.defer(“queueName”, “MyModel”, “myMethod”, this.id, param1, param2, etc..);
}
public static void myStaticMethod(String param1, Int param2, etc..) {
// execute some application logic here …
}
public void deferMyStaticMethod(String param1, Int param2, etc..) {
ModelTaskInvoker.deferStatic(“queueName”, “MyModel”, “myMethod”, param1, param2, etc..);
}
}
Your model must have a Long Id and a method to find it by this id.
Your methods must have only simple type parameters.
- / module:deferer
application.deferer.task=GAETask
%test.application.deferer.task=MockTask
possible values : GAETask, PlayTask, MockTask
ModelTaskInvoker.classPrefix = “models.”;
ModelTaskInvoker.findByIdMethodName = “findById”;