/** * Convenience method for calling process skip listener, so that it can be * called from multiple places. * * @param item the item that is skipped * @param e the cause of the skip */ private void callProcessSkipListener(I item, Throwable e) { try { getListener().onSkipInProcess(item, e); } catch (RuntimeException ex) { throw new SkipListenerFailedException("Fatal exception in SkipListener.", ex, e); } }
/** * Test method for * {@link org.springframework.batch.core.listener.MulticasterBatchListener#onSkipInWrite(java.lang.Object, java.lang.Throwable)} * . */ @Test public void testOnSkipInProcess() { multicast.register(new SkipListenerSupport<Object,Object>() { @Override public void onSkipInProcess(Object item, Throwable t) { count++; super.onSkipInWrite(item, t); } }); multicast.onSkipInProcess(null, new RuntimeException("foo")); assertEquals(1, count); }
@Override public O doWithRetry(RetryContext context) throws Exception { try { return doTransform(item); } catch (Exception e) { if (shouldSkip(skipPolicy, e, contribution.getStepSkipCount())) { // If we are not re-throwing then we should check if // this is skippable contribution.incrementProcessSkipCount(); logger.debug("Skipping after failed process with no rollback", e); // If not re-throwing then the listener will not be // called in next chunk. getListener().onSkipInProcess(item, e); } else { getListener().onRetryProcessException(item, e); if (rollbackClassifier.classify(e)) { // Default is to rollback unless the classifier // allows us to continue throw e; } else { throw e; } } } return null; }
/** * Test method for * {@link org.springframework.batch.core.listener.MulticasterBatchListener#onSkipInWrite(java.lang.Object, java.lang.Throwable)} * . */ @Test public void testOnSkipInProcessFails() { multicast.register(new SkipListenerSupport<Object,Object>() { @Override public void onSkipInProcess(Object item, Throwable t) { count++; throw new RuntimeException("foo"); } }); try { multicast.onSkipInProcess(null, new RuntimeException("bar")); fail("Expected RuntimeException"); } catch (RuntimeException e) { // expected String message = e.getMessage(); assertEquals("Wrong message: " + message, "foo", message); } assertEquals(1, count); }
/** * Convenience method for calling process skip listener, so that it can be * called from multiple places. * * @param item the item that is skipped * @param e the cause of the skip */ private void callProcessSkipListener(I item, Throwable e) { try { getListener().onSkipInProcess(item, e); } catch (RuntimeException ex) { throw new SkipListenerFailedException("Fatal exception in SkipListener.", ex, e); } }
/** * Convenience method for calling process skip listener, so that it can be * called from multiple places. * * @param item the item that is skipped * @param e the cause of the skip */ private void callProcessSkipListener(I item, Throwable e) { try { getListener().onSkipInProcess(item, e); } catch (RuntimeException ex) { throw new SkipListenerFailedException("Fatal exception in SkipListener.", ex, e); } }
/** * Convenience method for calling process skip listener, so that it can be * called from multiple places. * * @param item the item that is skipped * @param e the cause of the skip */ private void callProcessSkipListener(I item, Throwable e) { try { getListener().onSkipInProcess(item, e); } catch (RuntimeException ex) { throw new SkipListenerFailedException("Fatal exception in SkipListener.", ex, e); } }
/** * Convenience method for calling process skip listener, so that it can be * called from multiple places. * * @param item the item that is skipped * @param e the cause of the skip */ private void callProcessSkipListener(I item, Throwable e) { try { getListener().onSkipInProcess(item, e); } catch (RuntimeException ex) { throw new SkipListenerFailedException("Fatal exception in SkipListener.", ex, e); } }
@Override public O doWithRetry(RetryContext context) throws Exception { try { return doTransform(item); } catch (Exception e) { if (shouldSkip(skipPolicy, e, contribution.getStepSkipCount())) { // If we are not re-throwing then we should check if // this is skippable contribution.incrementProcessSkipCount(); logger.debug("Skipping after failed process with no rollback", e); // If not re-throwing then the listener will not be // called in next chunk. getListener().onSkipInProcess(item, e); } else { getListener().onRetryProcessException(item, e); if (rollbackClassifier.classify(e)) { // Default is to rollback unless the classifier // allows us to continue throw e; } else { throw e; } } } return null; }
@Override public O doWithRetry(RetryContext context) throws Exception { try { return doTransform(item); } catch (Exception e) { if (shouldSkip(skipPolicy, e, contribution.getStepSkipCount())) { // If we are not re-throwing then we should check if // this is skippable contribution.incrementProcessSkipCount(); logger.debug("Skipping after failed process with no rollback", e); // If not re-throwing then the listener will not be // called in next chunk. getListener().onSkipInProcess(item, e); } else { getListener().onRetryProcessException(item, e); if (rollbackClassifier.classify(e)) { // Default is to rollback unless the classifier // allows us to continue throw e; } else { throw e; } } } return null; }
@Override public O doWithRetry(RetryContext context) throws Exception { try { return doTransform(item); } catch (Exception e) { if (shouldSkip(skipPolicy, e, contribution.getStepSkipCount())) { // If we are not re-throwing then we should check if // this is skippable contribution.incrementProcessSkipCount(); logger.debug("Skipping after failed process with no rollback", e); // If not re-throwing then the listener will not be // called in next chunk. getListener().onSkipInProcess(item, e); } else { getListener().onRetryProcessException(item, e); if (rollbackClassifier.classify(e)) { // Default is to rollback unless the classifier // allows us to continue throw e; } else { throw e; } } } return null; }