[Index]

jmx:client


Connect to an Oddjob jmx:server. This job allows remote jobs to be monitored and controlled from a local Oddjob.

This service will run until it is manually stopped or until the connection to the remote server is lost. If this job is stopped it's state will be COMPLETE, if the connection is lost the state state will be EXCEPTION.

To access and control jobs on a server from within a configuration file this client must have an id. If the client has an id of 'freds-pc' and the job on the server has an id of 'freds-job'. The job on the server can be accessed from the client using the expression ${freds-pc/freds-job}.


Property Summary

connection The JMX service URL.
environment The environment.
handlerFactories Additional handler factories that allow any interface to be invoked from a remote Oddjob.
heartbeat The heart beat interval, in milliseconds.
logPollingInterval The number of milliseconds between polling for new log events.
maxConsoleLines The maximum number of console lines to retrieve for any component.
maxLoggerLines The maximum number of log lines to retrieve for any component.
name A name, can be any text.
url This property is now deprecated in favour of connection which reflects that the connection string no longer need only be a full JMX URL.

Example Summary

Example 1 Connect to a remote server that is using the Platform MBean Server.
Example 2 To create a connection to a remote server that is using an RMI registry using the full form of the JMX URL.
Example 3 Connect, run a remote job, and disconnect.
Example 4 Connect using a username and password to a secure server.
Example 5 A local job triggers when a server job runs.

Property Detail

connection

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo. If not provided the client connects to the Platform MBean Server for the current VM.

The JMX service URL. This is can be either the full blown convoluted JMX Service URL starting service.jmx.... or it can just be the last part of the form hostname[:port][/instance-name].

environment

Configured ByELEMENT
AccessREAD_WRITE
RequiredNo.

The environment. Typically username/password credentials.

handlerFactories

Configured ByELEMENT
AccessREAD_WRITE
RequiredNo.

Additional handler factories that allow any interface to be invoked from a remote Oddjob.

heartbeat

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNot, defaults to 5 seconds.

The heart beat interval, in milliseconds.

logPollingInterval

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo.

The number of milliseconds between polling for new log events. Defaults to 5.

maxConsoleLines

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo.

The maximum number of console lines to retrieve for any component.

maxLoggerLines

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo.

The maximum number of log lines to retrieve for any component.

name

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo.

A name, can be any text.

url

Configured ByATTRIBUTE
AccessWRITE_ONLY
RequiredNo.

This property is now deprecated in favour of connection which reflects that the connection string no longer need only be a full JMX URL.


Examples

Example 1

Connect to a remote server that is using the Platform MBean Server. This example also demonstrates using the value of a remote jobs property.

<oddjob id="this" xmlns:jmx="http://rgordon.co.uk/oddjob/jmx">
  <job>
    <sequential>
      <jobs>
        <jmx:client id="remote" connection="${this.args[0]}"/>
        <echo>${remote/echo.text}</echo>
        <stop job="${remote}"/>
      </jobs>
    </sequential>
  </job>
</oddjob>

Note that the stop is required otherwise Oddjob wouldn't exit. An Alternative to using stop, would be to make the client a child of a sequential with an org.oddjob.state.ServiceManagerStateOp operator.

Here's an example of the command used to launch it:

 java -jar C:\Users\rob\projects\oddjob\run-oddjob.jar -f C:\Users\rob\projects\oddjob\test\java\org\oddjob\jmx\PlatformMBeanClientExample.xml localhost:13013
 

This configuration is the client side of the first example in jmx:server.

Example 2

To create a connection to a remote server that is using an RMI registry using the full form of the JMX URL.

<jmx:client id="freds-pc" name="Connection to Freds PC" url="service:jmx:rmi:///jndi/rmi://${hosts.freds-pc}/freds-oddjob-server" xmlns:jmx="http://rgordon.co.uk/oddjob/jmx"/>

Example 3

Connect, run a remote job, and disconnect.

<oddjob>
  <job>
    <sequential>
      <jobs>
        <jmx:client id="freds-pc" name="Oddjob Client" url="service:jmx:rmi:///jndi/rmi://${hosts.freds-pc}/freds-oddjob-server" xmlns:jmx="http://rgordon.co.uk/oddjob/jmx"/>
        <run job="${freds-pc/server-jobs/greeting}" join="true"/>
        <stop job="${freds-pc}"/>
      </jobs>
    </sequential>
  </job>
</oddjob>

The run job starts the server job but doesn't wait for it to complete. We would need to add a wait job for that.

Example 4

Connect using a username and password to a secure server.

<jmx:client connection="localhost/my-oddjob" xmlns:jmx="http://rgordon.co.uk/oddjob/jmx">
    <environment>
        <jmx:client-credentials username="username" password="password"/>
    </environment>
</jmx:client>

Example 5

A local job triggers when a server job runs.

<oddjob>
    <job>
        <sequential>
            <jobs>
                <jmx:client id="freds-pc" name="Oddjob Client" url="service:jmx:rmi:///jndi/rmi://${hosts.freds-pc}/freds-oddjob-server" xmlns:jmx="http://rgordon.co.uk/oddjob/jmx"/>
                <scheduling:trigger on="${freds-pc/server-jobs/greeting}" xmlns:scheduling="http://rgordon.co.uk/oddjob/scheduling">
                    <job>
                        <sequential>
                            <jobs>
                                <echo id="local-job">Server Job Ran!</echo>
                                <stop job="${freds-pc}"/>
                            </jobs>
                        </sequential>
                    </job>
                </scheduling:trigger>
            </jobs>
        </sequential>
    </job>
</oddjob>


(c) R Gordon Ltd 2005 - Present