Layer7 Access Management

Expand all | Collapse all

Automate a clean-up process for Wildfly JMS Queue

  • 1.  Automate a clean-up process for Wildfly JMS Queue

    Posted 06-30-2017 05:52 PM
      |   view attached

    Hello Team,

     

    I have notes on how to ensure that JBOSS/Wildlfy is shutdown properly, but sometimes if a JBOSS/Wildfly process that is killed, it may be necessary to clean out the JMS queue.

     

    Prior notes:

    CA IAMSuite - Ensure JBOSS/Wildfly Shuts down Correctly 

     

    This process assumes that FILE REPLICATION configuration is used, and NOT SHARED configuration of the JMS queue.

     

    Below is a shell script, that assumes JBOSS/Wildfly is currently running on a server.

    I have this configure for two (2) instances of JBOSS/Wildfly.  It may be modified for your environment.

     

     

     

    Script copied to JIVE screens for better search results:

     

      

    #!/bin/bash

     ##########################################################################

    #

    # If JBOSS is interrupted during startup, the JMS queue may impact later

    # startup of JBOSS

    #

    #

    ##########################################################################

     

    # Variables

    BACKUPDATE=`date +%Y%m%d_%H%M%S_%N`

    JBOSS_VER=jboss-eap-6.2

    JBOSS_ROOT=/opt/CA/jboss

    JBOSS01_IM_HOME="$JBOSS_ROOT"/im_01/"$JBOSS_VER"

    JBOSS02_IM_HOME="$JBOSS_ROOT"/im_02/"$JBOSS_VER"

    JBOSS01_IP_HOME="$JBOSS_ROOT"/ip_01/"$JBOSS_VER"

    JBOSS01_IG_HOME="$JBOSS_ROOT"/ig_01/"$JBOSS_VER"

    USER=jboss

    GROUP=jboss

    JBOSS01_PIDFILE=$JBOSS01_IM_HOME/standalone/log/jboss-im_01.pid

    JBOSS02_PIDFILE=$JBOSS01_IM_HOME/standalone/log/jboss-im_02.pid

      

    # Check running

    ps -ef | grep -v grep | grep jboss

      

    # init.d

    /etc/init.d/jboss-im_01 stop  >   /dev/null 2>&1

    /etc/init.d/jboss-im_02 stop  >   /dev/null 2>&1

      

    # Kill jboss

    kill -9 `ps -ef | grep jboss | grep -v grep | awk '{print $2}'`  >   /dev/null 2>&1

      

    # Clean out JMS Hornetq temp and data folder

    rm -rf  $JBOSS01_IM_HOME/standalone/tmp/*  >   /dev/null 2>&1

    ls -al  $JBOSS01_IM_HOME/standalone/tmp/

    rm -rf  $JBOSS02_IM_HOME/standalone/tmp/*  >   /dev/null 2>&1

    ls -al  $JBOSS02_IM_HOME/standalone/tmp/

    rm -rf  $JBOSS01_IM_HOME/standalone/data/* >   /dev/null 2>&1

    ls -al  $JBOSS01_IM_HOME/standalone/data/

    rm -rf  $JBOSS02_IM_HOME/standalone/data/* >   /dev/null 2>&1

    ls -al  $JBOSS02_IM_HOME/standalone/data/

      

    # Clean up pid files

    rm -rf $JBOSS01_PIDFILE >   /dev/null 2>&1

    rm -rf $JBOSS02_PIDFILE >   /dev/null 2>&1

     

    # Completed

    echo "Done"

     

     

     

     

     

    After the above script has cleaned out the JMS files, startup up JBOSS/Wildfly and monitor the logs for any error messages due to prior JMS configurations/files.

     

     

     

    Cheers,

     

    Alan



  • 2.  Re: Automate a clean-up process for Wildfly JMS Queue

    Posted 06-30-2017 06:47 PM

    Thank you for sharing this tip with the community Alan!

    Automate a clean-up process for Wildfly JMS Queue 



  • 3.  Re: Automate a clean-up process for Wildfly JMS Queue

    Posted 12-30-2017 05:37 PM

    Thanks for sharing Alan. To add, care needs to be implemented when using this process across all cluster members. As mentioned in the post already, the process clears out the JMS queue. This includes clearing information pending for processing. It would be best that this JMS clearing does not occur each time start/stop occurs but rather on a 'need-to-clear' basis.



  • 4.  Re: Automate a clean-up process for Wildfly JMS Queue

     
    Posted 01-02-2018 04:02 PM

    Alan,

     

    Thanks for sharing.. Additionally you can also move log file, so the next start has a clean log.  

     

    -Bala