Skip to content

job monitoring

Mahmoud Ben Hassine edited this page Feb 7, 2020 · 5 revisions

Enable JMX monitoring

Easy Batch allows you to monitor job execution and progress at runtime using JMX. The JMX MBean named org.jeasy.batch.jmx.monitor:name=YourJobName exposes the following attributes:

  • The job start and end times
  • The job status
  • The number of read records
  • The number of written records
  • The number of filtered records
  • The number of errors

In order to register this JMX MBean, you should enable JMX monitoring at application startup:

Job job = new JobBuilder()
    .enableJmx(true)
    .build();

You can then use any standard JMX compliant tool such as VisualVM to visualize monitoring attributes. The screenshot below shows an example of job monitoring using VisualVM:

JMX monitoring is disabled by default.

NB: You must ensure that JMX-enabled jobs have a unique name. Otherwise, notifications will be mixed or lost.

Listen to JMX notifications

When you enable JMX monitoring, the job monitor will automatically send notifications about execution progress. In order to listen to these notifications, you need to:

  • Specify the JMX port on which the job monitor should send notifications. This can be done using the com.sun.management.jmxremote.port JVM parameter
  • Use a JobMonitorProxy with a JobMonitoringListener to handle notifications

You can find an example of how to use these APIs in the JMX tutorial.

Clone this wiki locally