Introduction
This example comes with an MBean and server. It shows how jobs can be configured to run and monitor this MBean.
Feature Status
Display feature availability | ||||
---|---|---|---|---|
|
Downloads
- jmx.zip - job configuration files
- sos.jmx.jar - library with JMX Job
- jmx_server.zip - MBean server startscripts
- sos.howto.jar - Example MBean implementation and server
- sos.howto.zip - MBean Sources
Instructions
- Download the JMX Remote Reference Implementation and the JMX Implementation from http://java.sun.com/javase/technologies/core/mntr-mgmt/javamanagement/download.jsp
- Unzip all files from
jmx.zip
into the ./config/live folder of your JobScheduler. - Put
sos.jmx.jar
into thelib
directory the JobScheduler. - Create a directory for the MBean server somewhere on your system and unzip
jmx_server.zip
into that directory. - Put
jmxremote.jar
,jmxremote_optional.jar
,jmxri.jar
(from the Sun downloads) andsos.howto.jar
into that directory. - Open a shell and start the jmx server with
server.sh
orserver.cmd
- Open the
config/factory.ini
file of your job Scheduler and add thelib
directories of the two Sun jmx downloads to theclasspath
. (E.g. add ":/home/test/jmx-1_2_1-bin/lib/*.jar:/home/test/jmx/jmxremote-1_0_1-bin/lib/*.jar" with ";" instead of ":" on Windows to the existing classpath) - Start the JobScheduler
- Open the web interface of the JobScheduler in your browser using http://scheduler_host:scheduler_port
Asynchronous execution
The JobSchedulerJMXManager Job can run launch and check MBeans for ansynchronous execution.
...
The job will now cancel the Execution of the MBean. This might take a moment.
Synchronous execution with a standalone job
The JobSchedulerJMXManager Job can run execute Methods synchronously in an MBean.
...
The job will now execute an MBean function called "execute" and pass it's parameters to that function. Watch the output of the server console. You should be able to find your parameters there. Once the method has been exectued, the job will not be running anymore.
Synchronous execution in a job chain
The JobSchedulerJMXManager Job can be used as part of a job chain to execute Methods synchronously in an MBean as a step of a job chain.
...
The job Scheduler will now first execute a simple shell job and then execute the "execute" function of the MBean. Open the order history and see the log of the order to confirm.
How it works
The JobSchedulerJMXManager job can be configured to perform different actions. The following actions are available:
...
Have a look at the job definitions. The jobs are configured with <delay_after_error> elements. This causes the job to repeat in case of an error. For synchronous execution this means, that the function will be executed again. With the launch,check,cancel
configuration of the asynchronous job, this will result in a re-launch of the job if an error occurs during one of the periodic check actions.
Next steps
- Move the MBean server to another machine. Adjust the
config/live/samples/jmx/JMXMP.connector.params.xml
file to point to that other machine. - Start modifying the code of
SOSSample.java
to implement some real-life functions. - Take an existing java class and make it accessible as an MBean by creating an MBean interface for this class and adjusting the name of the
execute
method (or others) and the name of theState
attribute by job configuration.