logger.debug("Found result: " + payload); Long jobInstanceId = payload.getJobId(); Assert.state(jobInstanceId != null, "Message did not contain job instance id."); Assert.state(jobInstanceId.equals(localState.getJobId()), "Message contained wrong job instance id [" + jobInstanceId + "] should have been [" + localState.getJobId() + "]."); if (payload.isRedelivered()) { logger .warn("Redelivered result detected, which may indicate stale state. In the best case, we just picked up a timed out message " if (!payload.isSuccessful()) { throw new AsynchronousFailureException("Failure or interrupt detected in handler: " + payload.getMessage());
public Collection<StepContribution> getStepContributions() { List<StepContribution> contributions = new ArrayList<>(); for (ChunkResponse response : localState.pollChunkResponses()) { StepContribution contribution = response.getStepContribution(); if (logger.isDebugEnabled()) { logger.debug("Applying: " + response); } contributions.add(contribution); } return contributions; }
public ChunkResponse extract(ChunkResponse input, @Header(JmsHeaders.REDELIVERED) boolean redelivered) { if (logger.isDebugEnabled()) { logger.debug("Extracted redelivered flag for response, value="+redelivered); } return new ChunkResponse(input, redelivered); }
@Test public void testVanillaHandleChunk() throws Exception { handler.setChunkProcessor(new ChunkProcessor<Object>() { public void process(StepContribution contribution, Chunk<Object> chunk) throws Exception { count += chunk.size(); } }); StepContribution stepContribution = MetaDataInstanceFactory.createStepExecution().createStepContribution(); ChunkResponse response = handler.handleChunk(new ChunkRequest<>(0, StringUtils .commaDelimitedListToSet("foo,bar"), 12L, stepContribution)); assertEquals(stepContribution, response.getStepContribution()); assertEquals(12, response.getJobId().longValue()); assertTrue(response.isSuccessful()); assertEquals(2, count); }
@Test public void testSerializable() throws Exception { ChunkResponse result = (ChunkResponse) SerializationUtils.deserialize(SerializationUtils.serialize(response)); assertNotNull(result.getStepContribution()); assertEquals(new Long(111L), result.getJobId()); }
@Test public void testGetJobId() { assertEquals(new Long(111L), response.getJobId()); }
@Test public void testToString() { System.err.println(response.toString()); }
@Test public void testGetStepContribution() { assertNotNull(response.getStepContribution()); }
/** * * @see ChunkHandler#handleChunk(ChunkRequest) */ @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); }