JBoss 5.1 - Chapter 02 - Customizing JBoss AS Services
Jump to navigation
Jump to search
<slideshow style="nobleprog" headingmark="⌘" incmark="…" scaled="true" font="Trebuchet MS" >
- title
- Customizing JBoss AS Services
- author
- Bernard Slachta (NobleProg Ltd)
</slideshow>
Monitor JBoss AS services ⌘
Ways of monitoring JBoss AS ⌘
- Admin Console
- CLI - twiddle
- JMX Console
- Web Console (depricated)
Admin Console ⌘
- Short presentation of Admin Console
JMX Console ⌘
Works on managed beans (MBeans):
- show mbeans attributes
- invoke mbeans methods
Examples ⌘
- Start Hypersonic DB manager
- jboss/service=Hypersonic
- tweak the methods
- Invoke startDatabaseManager
- View JNDI tree
- jboss/service=JNDIView
- invoke view list
Twiddle ⌘
- used for scripting
- can do what JMX Console can do
# local connection (check JBOSS_HOME variable)
./twiddle.sh invoke jboss:service=JNDIView list true
# remote connection
./twiddle.sh -s t1.nobl.ws invoke jboss:service=JNDIView list true
JBoss AS thread pool ⌘
Configuring ThreadPool ⌘
- JNDI Thread Pool (conf/jboss-service.xml)
- Stateless Session Beans (SLBS) Pool (ejb3-interceptors-aop.xml)
- Connection Pools (*-ds.xml)
- Web Server connection pools (jbossweb.sar)
- Messaging thread pool (jca-jboss-beans.xml)
JNDI Connection Pools ⌘
Sample conf/jboss-service.xml file:
<mbean code="org.jboss.util.threadpool.BasicThreadPool"
name="jboss.system:service=ThreadPool">
<attribute name="Name">JBoss System Threads</attribute>
<attribute name="ThreadGroupName">System Threads</attribute>
<!-- How long a thread will live without any tasks in MS -->
<attribute name="KeepAliveTime">60000</attribute>
<!-- The max number of threads in the pool -->
<attribute name="MaximumPoolSize">10</attribute>
<!-- The max number of tasks before the queue is full -->
<attribute name="MaximumQueueSize">1000</attribute>
<!-- The behavior of the pool when a task is added and the queue is full.
abort - a RuntimeException is thrown
run - the calling thread executes the task
wait - the calling thread blocks until the queue has room
discard - the task is silently discarded without being run
discardOldest - check to see if a task is about to complete and enque
the new task if possible, else run the task in the calling thread
-->
<attribute name="BlockingMode">run</attribute>
</mbean>
MinimumPoolSize ⌘
- Idealy
MinimumPoolSize == MaximumPoolSize
Checking Server Status ⌘
- jboss.system:service=ThreadPool
- twiddle invoke "jboss.system:type=ServerInfo" listThreadDump
- twiddle invoke "jboss.system:type=ServerInfo" listThreadCpuUtilization
Memory Utilization ⌘
- Modify run.conf to use all available memory
Exercise ⌘
Create a test in JMeter, and check behavior of all blocking modes.
Configuring logging services ⌘
Components of log4j ⌘
- appenders
- layouts
- categories
Appenders ⌘
- an output destionation of log messages
Example from: conf/jboss-log4j.xml
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="Target" value="System.out"/>
<param name="Threshold" value="INFO"/>
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
</layout>
</appender>
Appender Types ⌘
- File Appenders
- DailyRollingFileAppender (rolling by time)
- RollingFileAppender (rolling by size of the file)
- Other File Appenders
- JMS
- SMNP
- SYSLOG
- JMX
- SMPT (email to admin)
See the jobss-log4j.xml for more detials
Threshold ⌘
- TRACE
- DEBUG
- INFO
- WARN
- ERROR
- FATAL
Logging Categories ⌘
CATEGORY IS NOT A CLASS
<category name="org.jboss.deployment.MainDeployer">
<priority value="ERROR" />
<appender-ref ref="TRAP_LOG"/>
</category>
Exercise - Filtering logs from a single application ⌘
- Find out exact class and j4log category of xplanner (use %C and $c options)
- Use the class to log all xplanner message to a separate file on the DEBUG priority
<appender name="XPLANNER_APPENDER" class="org.jboss.logging.appender.DailyRollingFileAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="File" value="${jboss.server.log.dir}/xplanner-server.log"/>
<param name="Append" value="true"/>
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<filter class="org.jboss.logging.filter.TCLFilter">
<param name="AcceptOnMatch" value="true"/>
<param name="DeployURL" value="xplanner-plus.war"/>
</filter>
<filter class="org.apache.log4j.varia.DenyAllFilter" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p |%c| %C (%t) %m%n"/>
</layout>
</appender>
Temporarily changing log settings ⌘
- go to JMX console
- jboss.system/service=Logging,type=Log4jService