List of usage examples for org.springframework.batch.integration.chunk ChunkRequest getStepContribution
public StepContribution getStepContribution()
From source file:org.springframework.batch.integration.chunk.ChunkProcessorChunkHandler.java
/** * * @see ChunkHandler#handleChunk(ChunkRequest) *//*from w w w . j a va2 s. co m*/ @ServiceActivator public ChunkResponse handleChunk(ChunkRequest<S> chunkRequest) throws Exception { if (logger.isDebugEnabled()) { logger.debug("Handling chunk: " + chunkRequest); } StepContribution stepContribution = chunkRequest.getStepContribution(); Throwable failure = process(chunkRequest, stepContribution); if (failure != null) { logger.debug("Failed chunk", failure); return new ChunkResponse(false, chunkRequest.getSequence(), chunkRequest.getJobId(), stepContribution, failure.getClass().getName() + ": " + failure.getMessage()); } if (logger.isDebugEnabled()) { logger.debug("Completed chunk handling with " + stepContribution); } return new ChunkResponse(true, chunkRequest.getSequence(), chunkRequest.getJobId(), stepContribution); }
From source file:org.springframework.batch.integration.chunk.ChunkRequestTests.java
@Test public void testSerializable() throws Exception { @SuppressWarnings("unchecked") ChunkRequest<String> result = (ChunkRequest<String>) SerializationUtils .deserialize(SerializationUtils.serialize(request)); assertNotNull(result.getStepContribution()); assertEquals(111L, result.getJobId()); assertEquals(2, result.getItems().size()); }