jmx:client


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

This job will run until it is manually stopped or until the remote server is stopped. If this job is stopped it's state will be COMPLETE, if the server stops this job's state will be INCOMPLETE.

To access and control jobs on a server from within a configuration file this client job 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

environment The environment.
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 The JMX service URL.

Example Summary

Example 1 To create a connection to a remote server.
Example 2 Connect, run a remote job, and disconnect.
Example 3 Connect using a username and password to a secure server.
Example 4 A local job triggers when a server job runs.

Property Detail

environment

Configured ByELEMENT
AccessREAD_WRITE
RequiredNo.

The environment. Typically username/password credentials.

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
AccessREAD_WRITE
RequiredNo. If not provided the client connects to the Platform MBean Server but this is really only useful for testing.

The JMX service URL.


Examples

Example 1

To create a connection to a remote server.

<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 2

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}"/>
                 <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 3

Connect using a username and password to a secure server.

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

Example 4

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) Rob Gordon 2005 - 2011