(Mostly) update for Spring Integration changes
This commit is contained in:
@@ -12,10 +12,10 @@ import org.springframework.batch.item.ItemStream;
|
||||
import org.springframework.batch.item.ItemStreamException;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.integration.message.BlockingSource;
|
||||
import org.springframework.integration.channel.MessageChannel;
|
||||
import org.springframework.integration.channel.PollableChannel;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.message.MessageTarget;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
public class ChunkMessageChannelItemWriter<T> extends StepExecutionListenerSupport implements ItemWriter<T>, ItemStream {
|
||||
@@ -28,9 +28,9 @@ public class ChunkMessageChannelItemWriter<T> extends StepExecutionListenerSuppo
|
||||
|
||||
private static final long DEFAULT_THROTTLE_LIMIT = 6;
|
||||
|
||||
private MessageTarget target;
|
||||
private MessageChannel target;
|
||||
|
||||
private BlockingSource<ChunkResponse> source;
|
||||
private PollableChannel source;
|
||||
|
||||
// TODO: abstract the state or make a factory for this writer?
|
||||
private LocalState localState = new LocalState();
|
||||
@@ -46,11 +46,13 @@ public class ChunkMessageChannelItemWriter<T> extends StepExecutionListenerSuppo
|
||||
this.throttleLimit = throttleLimit;
|
||||
}
|
||||
|
||||
public void setSource(BlockingSource<ChunkResponse> source) {
|
||||
// TODO: refactor to ChannelAdapter?
|
||||
public void setInputChannel(PollableChannel source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public void setTarget(MessageTarget target) {
|
||||
// TODO: re-evaluate the refactor to MessageChannel
|
||||
public void setOutputChannel(MessageChannel target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@@ -145,7 +147,8 @@ public class ChunkMessageChannelItemWriter<T> extends StepExecutionListenerSuppo
|
||||
* otherwise return null.
|
||||
*/
|
||||
private void getNextResult(long timeout) {
|
||||
Message<ChunkResponse> message = source.receive(timeout);
|
||||
@SuppressWarnings("unchecked")
|
||||
Message<ChunkResponse> message = (Message<ChunkResponse>) source.receive(timeout);
|
||||
if (message != null) {
|
||||
ChunkResponse payload = message.getPayload();
|
||||
Long jobInstanceId = payload.getJobId();
|
||||
@@ -174,7 +177,6 @@ public class ChunkMessageChannelItemWriter<T> extends StepExecutionListenerSuppo
|
||||
}
|
||||
|
||||
public int getSkipCount() {
|
||||
// TODO Auto-generated method stub
|
||||
return stepExecution.getSkipCount();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,9 +4,11 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.integration.annotation.Handler;
|
||||
import org.springframework.integration.annotation.MessageEndpoint;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@MessageEndpoint
|
||||
public class ChunkProcessorChunkHandler<S> implements ChunkHandler<S>, InitializingBean {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(ChunkProcessorChunkHandler.class);
|
||||
@@ -32,7 +34,7 @@ public class ChunkProcessorChunkHandler<S> implements ChunkHandler<S>, Initializ
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.integration.batch.slave.ChunkHandler#handleChunk(java.util.Collection)
|
||||
*/
|
||||
@Handler
|
||||
@ServiceActivator
|
||||
public ChunkResponse handleChunk(ChunkRequest<S> chunkRequest) {
|
||||
|
||||
logger.debug("Handling chunk: " + chunkRequest);
|
||||
|
||||
@@ -23,10 +23,10 @@ import org.springframework.batch.core.step.AbstractStep;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.beans.factory.annotation.Required;
|
||||
import org.springframework.integration.message.BlockingSource;
|
||||
import org.springframework.integration.channel.MessageChannel;
|
||||
import org.springframework.integration.channel.PollableChannel;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.message.MessageTarget;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -40,9 +40,9 @@ public class MessageOrientedStep extends AbstractStep {
|
||||
*/
|
||||
public static final String WAITING = MessageOrientedStep.class.getName() + ".WAITING";
|
||||
|
||||
private MessageTarget target;
|
||||
private MessageChannel outputChannel;
|
||||
|
||||
private BlockingSource<JobExecutionRequest> source;
|
||||
private PollableChannel source;
|
||||
|
||||
private static int MINUTE = 1000 * 60;
|
||||
|
||||
@@ -77,11 +77,11 @@ public class MessageOrientedStep extends AbstractStep {
|
||||
|
||||
/**
|
||||
* Public setter for the target.
|
||||
* @param target the target to set
|
||||
* @param outputChannel the target to set
|
||||
*/
|
||||
@Required
|
||||
public void setTarget(MessageTarget target) {
|
||||
this.target = target;
|
||||
public void setOutputChannel(MessageChannel outputChannel) {
|
||||
this.outputChannel = outputChannel;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,7 +89,7 @@ public class MessageOrientedStep extends AbstractStep {
|
||||
* @param source the source to set
|
||||
*/
|
||||
@Required
|
||||
public void setSource(BlockingSource<JobExecutionRequest> source) {
|
||||
public void setInputChannel(PollableChannel source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ public class MessageOrientedStep extends AbstractStep {
|
||||
executionContext.putString(WAITING, "true");
|
||||
// TODO: need these two lines to be atomic
|
||||
getJobRepository().update(stepExecution);
|
||||
target.send(new GenericMessage<JobExecutionRequest>(request));
|
||||
outputChannel.send(new GenericMessage<JobExecutionRequest>(request));
|
||||
waitForReply(request.getJobId());
|
||||
}
|
||||
|
||||
@@ -132,7 +132,8 @@ public class MessageOrientedStep extends AbstractStep {
|
||||
while (count++ < maxCount) {
|
||||
|
||||
// TODO: timeout?
|
||||
Message<JobExecutionRequest> message = source.receive(timeout);
|
||||
@SuppressWarnings("unchecked")
|
||||
Message<JobExecutionRequest> message = (Message<JobExecutionRequest>) source.receive(timeout);
|
||||
|
||||
if (message != null) {
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.beans.factory.annotation.Required;
|
||||
import org.springframework.integration.annotation.Handler;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -58,7 +58,7 @@ public class StepExecutionMessageHandler {
|
||||
this.jobRepository = jobRepository;
|
||||
}
|
||||
|
||||
@Handler
|
||||
@ServiceActivator
|
||||
public JobExecutionRequest handle(JobExecutionRequest request) {
|
||||
|
||||
// Hand off immediately if the job has already failed
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.springframework.batch.core.JobExecutionException;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.UnexpectedJobExecutionException;
|
||||
import org.springframework.batch.core.launch.JobLauncher;
|
||||
import org.springframework.integration.annotation.Handler;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
|
||||
/**
|
||||
* Message handler which uses strategies to convert a Message into a job and a
|
||||
@@ -27,7 +27,7 @@ public class JobLaunchingMessageHandler {
|
||||
this.jobLauncher = jobLauncher;
|
||||
}
|
||||
|
||||
@Handler
|
||||
@ServiceActivator
|
||||
public JobExecution launch(JobLaunchRequest request) {
|
||||
Job job = request.getJob();
|
||||
JobParameters jobParameters = request.getJobParameters();
|
||||
|
||||
Reference in New Issue
Block a user