Dust off JMX demo
This commit is contained in:
@@ -103,5 +103,13 @@ public class JobExecutionRequest extends AttributeAccessorSupport {
|
||||
public JobExecution getJobExecution() {
|
||||
return jobExecution;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName()+": "+jobExecution;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,6 +43,27 @@ public class MessageOrientedStep extends AbstractStep {
|
||||
|
||||
private MessageChannel replyChannel;
|
||||
|
||||
private int executionTimeoutMinutes = 30;
|
||||
|
||||
private long pollingInterval = 5;
|
||||
|
||||
/**
|
||||
* Public setter for the execution timeout in minutes. Defaults to 30.
|
||||
* @param executionTimeoutMinutes the timeout to set
|
||||
*/
|
||||
public void setExecutionTimeoutMinutes(int executionTimeoutMinutes) {
|
||||
this.executionTimeoutMinutes = executionTimeoutMinutes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Public setter for the polling interval in milliseconds while waiting for
|
||||
* replies signalling the end of the step. Defaults to 5.
|
||||
* @param pollingInterval the polling interval to set
|
||||
*/
|
||||
public void setPollingInterval(long pollingInterval) {
|
||||
this.pollingInterval = pollingInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Public setter for the requestChannel.
|
||||
* @param requestChannel the requestChannel to set
|
||||
@@ -88,7 +109,7 @@ public class MessageOrientedStep extends AbstractStep {
|
||||
return ExitStatus.FINISHED;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Do nothing.
|
||||
*
|
||||
@@ -97,7 +118,7 @@ public class MessageOrientedStep extends AbstractStep {
|
||||
@Override
|
||||
protected void open(ExecutionContext ctx) throws Exception {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Do nothing.
|
||||
*
|
||||
@@ -111,12 +132,12 @@ public class MessageOrientedStep extends AbstractStep {
|
||||
* @param expectedJobId
|
||||
*/
|
||||
private void waitForReply(Long expectedJobId) {
|
||||
// TODO: promote timeout to field and calculate count
|
||||
long timeout = 5;
|
||||
int count = 0;
|
||||
long timeout = pollingInterval;
|
||||
long maxCount = executionTimeoutMinutes * 1000 * 60 / timeout;
|
||||
long count = 0;
|
||||
|
||||
// TODO: use a ReponseCorrelator?, or just a SynchronousChannel
|
||||
while (count++ < 100) {
|
||||
while (count++ < maxCount) {
|
||||
|
||||
Message<?> message = replyChannel.receive(timeout);
|
||||
|
||||
@@ -144,7 +165,7 @@ public class MessageOrientedStep extends AbstractStep {
|
||||
}
|
||||
}
|
||||
|
||||
if (count >= 100) {
|
||||
if (count >= maxCount) {
|
||||
throw new StepExecutionTimeoutException("Timed out waiting for steps to execute.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.batch.core.JobParameters;
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class JobExecutionRequest {
|
||||
public class JobLaunchRequest {
|
||||
|
||||
private final Job job;
|
||||
private final JobParameters jobParameters;
|
||||
@@ -34,7 +34,7 @@ public class JobExecutionRequest {
|
||||
* @param job
|
||||
* @param jobParameters
|
||||
*/
|
||||
public JobExecutionRequest(Job job, JobParameters jobParameters) {
|
||||
public JobLaunchRequest(Job job, JobParameters jobParameters) {
|
||||
super();
|
||||
this.job = job;
|
||||
this.jobParameters = jobParameters;
|
||||
@@ -28,7 +28,7 @@ public class JobLaunchingMessageHandler {
|
||||
}
|
||||
|
||||
@Handler
|
||||
public JobExecution launch(JobExecutionRequest request) {
|
||||
public JobExecution launch(JobLaunchRequest request) {
|
||||
Job job = request.getJob();
|
||||
JobParameters jobParameters = request.getJobParameters();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user