在JBoss SOA 5.3.0.GA(JBoss AS的一种风格)下,我有一个包含多个WAR的EAR。取消部署EAR时,每个WAR大约需要5秒钟才能取消部署。
这归因于CatalinaEventHandler.stopContext(Context)
,其中完成了五秒钟的睡眠:
273 public void stopContext(Context context)
274 {
275 this.checkInit();
276
277 if (!this.exclude(context))
278 {
279 log.debug(this.sm.getString("modcluster.context.stop", context.getPath(), context.getParent().getName()));
280
281 // Send STOP-APP
282 MCMPRequest request = this.requestFactory.createStopRequest(context);
283
284 this.mcmpHandler.sendRequest(request);
285 Thread thr = Thread.currentThread();
286 try {
287 thr.sleep(5000); // Time for requests being processed.
288 } catch(Exception ex) {
289 }
290 }
291 }
有没有办法加速Web应用程序取消部署?
答案 0 :(得分:0)
基于CatalinaEventHandler.stopContext(Context)
源代码,没有简单的方法来加速Web应用程序的关闭。
但是,我使用了一种解决方法:我将5000
常量值(第287行)替换为系统属性中的值,编译并重新打包jboss-as/server/myServer/deploy/mod-cluster.sar/mod-cluster-1.0.10.GA_CP02.jar
(并从JAR中删除了签名信息)在MANIFEST.MF
和其他.SF
文件中:
// get the timeout
long timeout = 5000; // the default timeout
String propName = "org.jboss.modcluster.CatalinaEventHandler.stopContext.timeout";
String timeoutStr = System.getProperty(propName);
if (timeoutStr!=null) {
try {
timeout = Long.parseLong(timeoutStr);
} catch (NumberFormatException e) {
log.warn("could not parse "+propName+" : "+e.toString());
}
}
// wait for requests being processed
try {
thr.sleep(timeout);
} catch(Exception ex) {
}
然后我使用-Dorg.jboss.modcluster.CatalinaEventHandler.stopContext.timeout=50
启动服务器,我的Web应用程序非常快地执行关闭,因为等待时间仅为50毫秒。