Example usage for org.springframework.batch.integration.chunk ChunkRequest getStepContribution

List of usage examples for org.springframework.batch.integration.chunk ChunkRequest getStepContribution

Introduction

In this page you can find the example usage for org.springframework.batch.integration.chunk ChunkRequest getStepContribution.

Prototype

public StepContribution getStepContribution() 

Source Link

Usage

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());
}