Example usage for org.springframework.batch.integration.chunk ChunkResponse ChunkResponse

List of usage examples for org.springframework.batch.integration.chunk ChunkResponse ChunkResponse

Introduction

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

Prototype

public ChunkResponse(boolean status, int sequence, Long jobId, StepContribution stepContribution,
            @Nullable String message) 

Source Link

Usage

From source file:org.springframework.batch.integration.chunk.ChunkProcessorChunkHandler.java

/**
 *
 * @see ChunkHandler#handleChunk(ChunkRequest)
 *//*from   w w w .  j a v  a 2  s .c  o 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);

}