Question

Under JBoss SOA 5.3.0.GA (a flavor of JBoss AS), I have an EAR with several WARs. When the EAR is undeployed, each WAR takes about 5 seconds to be undeployed.

This is due to CatalinaEventHandler.stopContext(Context), where a a five second sleep is done:

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   }

Is there a way to speed-up the web applications undeployment ?

Was it helpful?

Solution

Based on the CatalinaEventHandler.stopContext(Context) source code, there is no easy way to speedup the web application shutdown.

However, I used a workaround: I replaced the 5000 constant value (line 287) by a value from the system properties, compiled and repackaged the jboss-as/server/myServer/deploy/mod-cluster.sar/mod-cluster-1.0.10.GA_CP02.jar (and removed the signing information from the JAR in MANIFEST.MF and other .SF file):

// 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) {
}

Then I start the server using -Dorg.jboss.modcluster.CatalinaEventHandler.stopContext.timeout=50 and my web applications do their shutdown very fast since the wait period is only 50 ms.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top