有没有人测试过谷歌应用引擎模块(目前处于预览阶段)?
文档说“有状态服务(例如 Memcache、Datastore和任务队列)由应用程序中的所有模块共享”,所以我测试了是否也是跨模块共享的数据存储回调,但我的测试似乎表明如果一个模块放置了一些东西,preput(或postput)事件只会为放置实体的模块触发。
这是预期的行为还是我错过了什么?这是代码:
模块1:
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
Key key = KeyFactory.createKey("kind", "id");
Entity e;
e = new Entity(key);
ds.put(e);
super.doPost(req, resp);
}
@PrePut(kinds = { "kind" })
void updateTimestamp(PutContext context) {
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
Key key = KeyFactory.createKey("ContatoreModulo1", "contatore");
Entity e;
int counter = 0;
try {
e = ds.get(key);
counter = Integer.parseInt(String.valueOf(e.getProperty("count")));
counter++;
} catch (EntityNotFoundException e1) {
e = new Entity(key);
}
e.setProperty("count", String.valueOf(counter));
ds.put(e);
throw new RuntimeException();
}
模块2:
@PrePut(kinds = { "kind" })
void updateTimestamp(PutContext context) {
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
Key key = KeyFactory.createKey("ContatoreModulo2", "contatore");
Entity e;
int counter = 0;
try {
e = ds.get(key);
counter = Integer.parseInt(String.valueOf(e.getProperty("count")));
counter++;
} catch (EntityNotFoundException e1) {
e = new Entity(key);
}
e.setProperty("count", String.valueOf(counter));
ds.put(e);
throw new RuntimeException();
}
简单地说,在 MODULE1 中,我放置了一个类型为“kind”的实体,然后在两个模块中,我尝试捕获该实体的 preput 回调,但我看到只有在 MODULE1 中声明的 preput 被调用...
提前致谢