我正在研究GAE + SpringMVC,在我的项目中,我编写了一个后端,但它运行了5次以上,但我想只运行一次后端。请检查下面的代码
@RequestMapping(value="/gDirectory/testBackend.htm" ,method=RequestMethod.GET)
public String testBackend(HttpServletRequest reg)
{
final Logger logger=Logger.getLogger(this.getClass().getName());
logger.warning("calling updateOrgChart.htm.....");
try {
String url="/gDirectory/testbackend1.htm";
Queue queue = QueueFactory.getDefaultQueue();
TaskOptions objTskOptions= TaskOptions.Builder.withUrl(url)
// .countdownMillis(countmilliseconds)
.header("Host", BackendServiceFactory.getBackendService().getBackendAddress("testbackend"))
.method(Method.GET);
queue.add(objTskOptions);
} catch(Exception e){
ErrorHandler.errorHandler(this.getClass().getName(), e);
logger.warning("Exception in adding oldcustomer..161."+e);
logger.warning("Exception in adding oldcustomer..161."+e.getMessage());
logger.warning("Exception in adding oldcustomer..161."+e.getLocalizedMessage());
}
return "testBackend";
}
Mybackend
@RequestMapping(value="/gDirectory/testbackend1.htm" ,method=RequestMethod.GET)
public String testBackend1(HttpServletRequest reg)
{
final Logger logger=Logger.getLogger(this.getClass().getName());
logger.warning("calling updateOrgChart.htm.....");
try {
logger.warning("This is my testbackend...........................");
LifecycleManager.getInstance().setShutdownHook(new ShutdownHook() {
public void shutdown() {
LifecycleManager.getInstance().interruptAllRequests();
}
});
} catch(Exception e){
ErrorHandler.errorHandler(this.getClass().getName(), e);
logger.warning("Exception in adding oldcustomer..161."+e);
logger.warning("Exception in adding oldcustomer..161."+e.getMessage());
logger.warning("Exception in adding oldcustomer..161."+e.getLocalizedMessage());
}
return "testBackend";
}
backend.xml
<backend name="testbackend">
<class>B2</class>
<instances>5</instances>
<options>
<dynamic>true</dynamic>
</options>
</backend>
这个后端运行超过7次......但我想只运行一次任何人帮助我
答案 0 :(得分:0)
您的后端任务可能会引发异常(可能会检查App Engine控制台中的日志),在这种情况下,推送队列将重试(使用指数后退)。如果是这种情况,控制台将显示最后的响应状态和重试次数。