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}
.
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 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. |
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | No. 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]
.
Configured By | ELEMENT |
Access | READ_WRITE |
Required | No. |
The environment. Typically username/password credentials.
Configured By | ELEMENT |
Access | READ_WRITE |
Required | No. |
Additional handler factories that allow any interface to be invoked from a remote Oddjob.
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | Not, defaults to 5 seconds. |
The heart beat interval, in milliseconds.
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | No. |
The number of milliseconds between polling for new log events. Defaults to 5.
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | No. |
The maximum number of console lines to retrieve for any component.
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | No. |
The maximum number of log lines to retrieve for any component.
Configured By | ATTRIBUTE |
Access | READ_WRITE |
Required | No. |
A name, can be any text.
Configured By | ATTRIBUTE |
Access | WRITE_ONLY |
Required | No. |
This property is now deprecated in favour of connection which reflects that the connection string no longer need only be a full JMX URL.
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.
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"/>
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.
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>
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>