Tuesday, January 22, 2013

Weblogic Fastswap Implementation

This time we come up with a interesting functionality FastSwap to SpeedUp Development .We tried to implement this "Fast Swap" feature in one of our J2EE Application that we developed and deploy it in Oracle Weblogic Application Server.
download
What is FastSwap and how can we achieve it ?
WebLogic’s FastSwap feature is:
        • Enabled using the WebLogic deployment descriptors
        • Available only if the domain is not running in production mode
        • Applicable only to Web applications that are not archived
When enabled:
        • WebLogic automatically reloads the modified Java class files within applications
        • Developers can perform iterative development without an explicit redeployment
On-demand deployment:
        • weblogic.xml:
          <fast-swap>true</fast-swap>
Implement fast swap in an Application?
1] Enable FastSwap Using Weblogic Deployment descriptors.
[thiru@localhost WEB-INF]$ cat weblogic.xml
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app
xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd
http://xmlns.oracle.com/weblogic/weblogic-web-app 
http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">

    <wls:weblogic-version>12.1.1</wls:weblogic-version>
    <wls:context-root>Monitoring_Application</wls:context-root>
    <wls:fast-swap>
        <wls:enabled>true</wls:enabled>
    </wls:fast-swap>
</wls:weblogic-web-app> 

2] Turn OFF production mode and switch ON development mode.
ole0
3] Deploy the applications in exploded form not in archived form.

Execution part ?
1] Modification of Java Class:
Added this line to to one of the Java Class in Monitoring_Application: System.out.println("From Weblogic GetServerDetails.Class!!").
ole1 (1)
So now we compiled this modified class and replaced the new .class file and access the application without "Any Rolling Restart" or "New Deployment".
image
We could see the added System.out.println statement output in weblogic server logs and also note that "Fast Swap" is updating Monitoring_Application at specified interval.

If we implement the same in our development environments , then i think it would reduce some amount of frequent "Deployments" and "Rolling Restarts" for a single class file modification.
Thanks to Oracle for this nice feature. Please share your suggestions and feedbacks.

References:
1] https://blogs.oracle.com/WebLogicServer/entry/using_fastswap_to_speed_up_dev
2] http://docs.oracle.com/cd/E12840_01/wls/docs103/deployment/deployunits.html#wp1053872

2 comments: