I need to know if JBoss startup is ready, then I can do something else. But how can I detect it?
Fortunately JBoss JMX MBean can help us.
1. Use twiddle.bat to get server infomation
%JBOSS_HOME%\bin\twiddle.bat -H get
Get the values of one or more MBean attributes
usage: get [options] <name> [<attr>+]
If no attribute names are given all readable attributes are retrieved
options:
–noprefix Do not display attribute name prefixes
– Stop processing options
%JBOSS_HOME%\bin\twiddle.bat get jboss:service=invoker,type=jrmp
ServerAddress=0.0.0.0
RMIClientSocketFactoryBean=null
StateString=Started
State=3
RMIServerSocketFactoryBean=org.jboss.net.sockets.DefaultSocketFactory@ad093076
EnableClassCaching=false
SecurityDomain=null
RMIServerSocketFactory=null
Backlog=200
RMIObjectPort=4444
Name=JRMPInvoker
RMIClientSocketFactory=null
2. Example:
I write a batch script like this:
REM *********************************** REM startup JBoss and then do something REM *********************************** @echo off REM start JBoss server start "JBoss4C server" /Min %JBOSS_HOME%binrun.bat REM use jboss.server MBean to detect JBoss start up ready or not REM continue to ping JBoss for max times set jcount=0 set MAXLOOP=100 :loop call %JBOSS_HOME%bintwiddle.bat get --noprefix "jboss.system:type=Server" Started > $flg REM if flag is "true" means JBoss start up ready! find /i /n /off "true" $flg REM ERRORLEVEL=0 success,ERRORLEVEL=1 fail if ERRORLEVEL 1 goto :FAIL_STARTUP goto :SUCCESS_STARTUP_JBOSS :FAIL_STARTUP echo JBoss startup not ready! echo wait... %jcount% if %jcount% == %MAXLOOP% goto :EXIT set /A jcount=%jcount%+1 goto :loop :SUCCESS_STARTUP_JBOSS echo JBoss start up ready! goto :dosomething :dosomething REM continue your task :EXIT exit @echo on REM *********************** REM shutdown JBoss window REM *********************** @echo off :SHUTDOWN_JBOSS4C REM shutdown JBoss server call %JBOSS_HOME%binshutdown.bat -S :CLOSE_WINDOW call taskkill /f /fi "windowtitle eq JBoss4C server*" | @cls :EXIT exit @echo on






No comments yet
Comments feed for this article