img
.
provides the class and infrastructure required for exposing job execution status to JMX. First, the
dependency to Spring Batch Admin, as shown in Table 23-1, should be added to the project.
Table 23-1. Maven Dependencies for Spring Batch Admin
Group ID
Artifact ID
Version
Description
1.2.1.RELEASE
Spring Batch Admin manager module
org.springframework.batch
spring-batch-
admin-manager
that includes the classes required for
exposing job status via JMX
The next step is to configure the required bean for Spring Batch and Spring Batch Admin to expose
the metrics via JMX. Listing 23-10 shows the bean definitions that need to be added to the configuration
file (batch-context.xml).
Listing 23-10. MBean for Spring Batch
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
<!-- Other code omitted -->
<!-- Spring Batch Admin for JMX -->
<context:mbean-export default-domain="spring.application"/>
.
<bean id="batchMBeanExporter" class="org.springframework.batch.admin.jmx
BatchMBeanExporter">
<property name="jobService">
<bean class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="target" ref="jobService" />
<property name="interceptorNames" value="cacheInterceptor" />
</bean>
</property>
<property name="defaultDomain" value="spring.application" />
</bean>
.
<bean id="cacheInterceptor" class="org.springframework.batch.admin.util
SimpleEhCacheInterceptor" />
.
<bean id="jobService" class="org.springframework.batch.admin.service
SimpleJobServiceFactoryBean">
<property name="jobRepository" ref="jobRepository" />
<property name="jobLauncher" ref="jobLauncher" />
<property name="jobLocator" ref="jobRegistry" />
<property name="dataSource" ref="dataSource" />
</bean>
</beans>
In Listing 23-10, the new bean definitions are highlighted in bold. First, the <context:mbean-export>
tag is defined to instruct Spring to scan for classes with related JMX annotations metadata. This is the
mechanism that Spring Batch Admin uses for exposing its status via JMX.
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home