1 Reply Latest reply on Jun 4, 2005 11:12 PM by Mark Lybarger

    expire all web sessions

    Mark Lybarger Apprentice

      i'm looking for a way to expire all web sessions, then call the garbage collector to help determine if we have a memory leak somewhere in our application. i've got the following ant task that'll list the sessions, but can't _easily_ get each session id into a property to call the expireSession method. is there another way to expire all sessions in a web app? the only option i can think of is to wrap this into some type of scripting task to parse the output.

      also, i'd like to be able to call an mbean on another server if possible. i can't figure out how to specify that here in my ant task.

      thanks
      ~mark

      my ant target:






      jboss.sessions ${jboss.sessions}


        • 1. Re: expire all web sessions
          Mark Lybarger Apprentice

          ok, i'll reply with my solution. running jboss.split will kill all sessions for the testWeb application:

          
           <target name="jboss.session">
           <jmx adapterName="jmx/rmi/RMIAdaptor" >
           <invoke target="jboss.web:type=Manager,path=/testWeb,host=localhost"
           operation="listSessionIds"
           property="some.property">
           </invoke>
           </jmx>
           <echo> session ids:${some.property}</echo>
          
           </target>
          
           <target name="jboss.split" depends="jboss.session">
          
           <script language="javascript">
           <![CDATA[
          
           importPackage(Packages.org.apache.tools.ant);
           importPackage(Packages.org.apache.tools.ant.taskdefs);
          
           var all_sessions = proj.getProperty("some.property");
          
           echoMessage("all session ids " + ":" + all_sessions);
          
           var sessions = all_sessions.split(" ");
          
           for (var i = 0; i<sessions.length; i++)
           {
           echoMessage("session id " + i + ":" + sessions + ":");
          
           runKillSession( sessions );
           }
          
           function runKillSession( sessionid )
           {
           var callTask = project.createTask("antcall");
           callTask.setTarget("jboss.kill.session");
          
           var param = callTask.createParam();
           param.setName("expire.session");
           param.setValue(sessionid);
          
           callTask.perform();
           }
          
           function echoMessage( message )
           {
           var echo = proj.createTask("echo");
           echo.setMessage(message);
           echo.perform();
           }
          
           ]]>
           </script>
           </target>
           <target name="jboss.kill.session">
           <echo> ${expire.session} </echo>
           <jmx adapterName="jmx/rmi/RMIAdaptor" >
           <invoke target="jboss.web:type=Manager,path=/testWeb,host=localhost"
           operation="expireSession"
           property="some.property">
           <parameter type="java.lang.String" arg="${expire.session}"/>
           </invoke>
           </jmx>
           </target>