Tabnine Logo
MulticasterBatchListener.onSkipInWrite
Code IndexAdd Tabnine to your IDE (free)

How to use
onSkipInWrite
method
in
org.springframework.batch.core.listener.MulticasterBatchListener

Best Java code snippets using org.springframework.batch.core.listener.MulticasterBatchListener.onSkipInWrite (Showing top 11 results out of 315)

origin: spring-projects/spring-batch

/**
 * Test method for
 * {@link org.springframework.batch.core.listener.MulticasterBatchListener#onSkipInWrite(java.lang.Object, java.lang.Throwable)}
 * .
 */
@Test
public void testOnSkipInWrite() {
  multicast.register(new SkipListenerSupport<Object,Object>() {
    @Override
    public void onSkipInWrite(Object item, Throwable t) {
      count++;
      super.onSkipInWrite(item, t);
    }
  });
  multicast.onSkipInWrite(null, new RuntimeException("foo"));
  assertEquals(1, count);
}
origin: spring-projects/spring-batch

/**
 * Test method for
 * {@link org.springframework.batch.core.listener.MulticasterBatchListener#onSkipInWrite(java.lang.Object, java.lang.Throwable)}
 * .
 */
@Test
public void testOnSkipInWriteFails() {
  multicast.register(new SkipListenerSupport<Object,Object>() {
    @Override
    public void onSkipInWrite(Object item, Throwable t) {
      count++;
      throw new RuntimeException("foo");
    }
  });
  try {
    multicast.onSkipInWrite(null, new RuntimeException("bar"));
    fail("Expected RuntimeException");
  }
  catch (RuntimeException e) {
    // expected
    String message = e.getMessage();
    assertEquals("Wrong message: " + message, "foo", message);
  }
  assertEquals(1, count);
}
origin: spring-projects/spring-batch

private void callSkipListeners(final Chunk<I> inputs, final Chunk<O> outputs) {
  for (SkipWrapper<I> wrapper : inputs.getSkips()) {
    I item = wrapper.getItem();
    if (item == null) {
      continue;
    }
    Throwable e = wrapper.getException();
    callProcessSkipListener(item, e);
  }
  for (SkipWrapper<O> wrapper : outputs.getSkips()) {
    Throwable e = wrapper.getException();
    try {
      getListener().onSkipInWrite(wrapper.getItem(), e);
    }
    catch (RuntimeException ex) {
      throw new SkipListenerFailedException("Fatal exception in SkipListener.", ex, e);
    }
  }
  // Clear skips if we are possibly going to process this chunk again
  outputs.clearSkips();
  inputs.clearSkips();
}
origin: spring-projects/spring-batch

  @Override
  @SuppressWarnings({ "unchecked", "rawtypes" })
  public Object doWithRetry(RetryContext context) throws Exception {
    chunkMonitor.setChunkSize(chunk.size());
    try {
      doPersist(contribution, chunk);
    }
    catch (Exception e) {
      if (shouldSkip(skipPolicy, e, contribution.getStepSkipCount())) {
        // Per section 9.2.7 of JSR-352, the SkipListener receives all the items within the chunk 						 
        ((MulticasterBatchListener) getListener()).onSkipInWrite(chunk.getItems(), e);
      } else {
        getListener().onRetryWriteException((List<Object>) chunk.getItems(), e);
        if (rollbackClassifier.classify(e)) {
          throw e;
        }
      }
      /*
       * If the exception is marked as no-rollback, we need to
       * override that, otherwise there's no way to write the
       * rest of the chunk or to honour the skip listener
       * contract.
       */
      throw new ForceRollbackForWriteSkipException(
          "Force rollback on skippable exception so that skipped item can be located.", e);
    }
    contribution.incrementWriteCount(chunk.size());
    return null;
  }
};
origin: org.springframework.batch/org.springframework.batch.core

private void callSkipListeners(final Chunk<I> inputs, final Chunk<O> outputs) {
  for (SkipWrapper<I> wrapper : inputs.getSkips()) {
    I item = wrapper.getItem();
    if (item == null) {
      continue;
    }
    Throwable e = wrapper.getException();
    callProcessSkipListener(item, e);
  }
  for (SkipWrapper<O> wrapper : outputs.getSkips()) {
    Throwable e = wrapper.getException();
    try {
      getListener().onSkipInWrite(wrapper.getItem(), e);
    }
    catch (RuntimeException ex) {
      throw new SkipListenerFailedException("Fatal exception in SkipListener.", ex, e);
    }
  }
  // Clear skips if we are possibly going to process this chunk again
  outputs.clearSkips();
  inputs.clearSkips();
}
origin: org.springframework.batch/spring-batch-core

private void callSkipListeners(final Chunk<I> inputs, final Chunk<O> outputs) {
  for (SkipWrapper<I> wrapper : inputs.getSkips()) {
    I item = wrapper.getItem();
    if (item == null) {
      continue;
    }
    Throwable e = wrapper.getException();
    callProcessSkipListener(item, e);
  }
  for (SkipWrapper<O> wrapper : outputs.getSkips()) {
    Throwable e = wrapper.getException();
    try {
      getListener().onSkipInWrite(wrapper.getItem(), e);
    }
    catch (RuntimeException ex) {
      throw new SkipListenerFailedException("Fatal exception in SkipListener.", ex, e);
    }
  }
  // Clear skips if we are possibly going to process this chunk again
  outputs.clearSkips();
  inputs.clearSkips();
}
origin: org.springframework.batch.core/org.motechproject.org.springframework.batch.core

private void callSkipListeners(final Chunk<I> inputs, final Chunk<O> outputs) {
  for (SkipWrapper<I> wrapper : inputs.getSkips()) {
    I item = wrapper.getItem();
    if (item == null) {
      continue;
    }
    Throwable e = wrapper.getException();
    callProcessSkipListener(item, e);
  }
  for (SkipWrapper<O> wrapper : outputs.getSkips()) {
    Throwable e = wrapper.getException();
    try {
      getListener().onSkipInWrite(wrapper.getItem(), e);
    }
    catch (RuntimeException ex) {
      throw new SkipListenerFailedException("Fatal exception in SkipListener.", ex, e);
    }
  }
  // Clear skips if we are possibly going to process this chunk again
  outputs.clearSkips();
  inputs.clearSkips();
}
origin: apache/servicemix-bundles

private void callSkipListeners(final Chunk<I> inputs, final Chunk<O> outputs) {
  for (SkipWrapper<I> wrapper : inputs.getSkips()) {
    I item = wrapper.getItem();
    if (item == null) {
      continue;
    }
    Throwable e = wrapper.getException();
    callProcessSkipListener(item, e);
  }
  for (SkipWrapper<O> wrapper : outputs.getSkips()) {
    Throwable e = wrapper.getException();
    try {
      getListener().onSkipInWrite(wrapper.getItem(), e);
    }
    catch (RuntimeException ex) {
      throw new SkipListenerFailedException("Fatal exception in SkipListener.", ex, e);
    }
  }
  // Clear skips if we are possibly going to process this chunk again
  outputs.clearSkips();
  inputs.clearSkips();
}
origin: org.springframework.batch/spring-batch-core

  @Override
  @SuppressWarnings({ "unchecked", "rawtypes" })
  public Object doWithRetry(RetryContext context) throws Exception {
    chunkMonitor.setChunkSize(chunk.size());
    try {
      doPersist(contribution, chunk);
    }
    catch (Exception e) {
      if (shouldSkip(skipPolicy, e, contribution.getStepSkipCount())) {
        // Per section 9.2.7 of JSR-352, the SkipListener receives all the items within the chunk 						 
        ((MulticasterBatchListener) getListener()).onSkipInWrite(chunk.getItems(), e);
      } else {
        getListener().onRetryWriteException((List<Object>) chunk.getItems(), e);
        if (rollbackClassifier.classify(e)) {
          throw e;
        }
      }
      /*
       * If the exception is marked as no-rollback, we need to
       * override that, otherwise there's no way to write the
       * rest of the chunk or to honour the skip listener
       * contract.
       */
      throw new ForceRollbackForWriteSkipException(
          "Force rollback on skippable exception so that skipped item can be located.", e);
    }
    contribution.incrementWriteCount(chunk.size());
    return null;
  }
};
origin: apache/servicemix-bundles

  @Override
  @SuppressWarnings({ "unchecked", "rawtypes" })
  public Object doWithRetry(RetryContext context) throws Exception {
    chunkMonitor.setChunkSize(chunk.size());
    try {
      doPersist(contribution, chunk);
    }
    catch (Exception e) {
      if (shouldSkip(skipPolicy, e, contribution.getStepSkipCount())) {
        // Per section 9.2.7 of JSR-352, the SkipListener receives all the items within the chunk 						 
        ((MulticasterBatchListener) getListener()).onSkipInWrite(chunk.getItems(), e);
      } else {
        getListener().onRetryWriteException((List<Object>) chunk.getItems(), e);
        if (rollbackClassifier.classify(e)) {
          throw e;
        }
      }
      /*
       * If the exception is marked as no-rollback, we need to
       * override that, otherwise there's no way to write the
       * rest of the chunk or to honour the skip listener
       * contract.
       */
      throw new ForceRollbackForWriteSkipException(
          "Force rollback on skippable exception so that skipped item can be located.", e);
    }
    contribution.incrementWriteCount(chunk.size());
    return null;
  }
};
origin: org.springframework.batch.core/org.motechproject.org.springframework.batch.core

  @Override
  @SuppressWarnings({ "unchecked", "rawtypes" })
  public Object doWithRetry(RetryContext context) throws Exception {
    chunkMonitor.setChunkSize(chunk.size());
    try {
      doPersist(contribution, chunk);
    }
    catch (Exception e) {
      if (shouldSkip(skipPolicy, e, contribution.getStepSkipCount())) {
        // Per section 9.2.7 of JSR-352, the SkipListener receives all the items within the chunk 						 
        ((MulticasterBatchListener) getListener()).onSkipInWrite(chunk.getItems(), e);
      } else {
        getListener().onRetryWriteException((List<Object>) chunk.getItems(), e);
        if (rollbackClassifier.classify(e)) {
          throw e;
        }
      }
      /*
       * If the exception is marked as no-rollback, we need to
       * override that, otherwise there's no way to write the
       * rest of the chunk or to honour the skip listener
       * contract.
       */
      throw new ForceRollbackForWriteSkipException(
          "Force rollback on skippable exception so that skipped item can be located.", e);
    }
    contribution.incrementWriteCount(chunk.size());
    return null;
  }
};
org.springframework.batch.core.listenerMulticasterBatchListeneronSkipInWrite

Popular methods of MulticasterBatchListener

  • afterProcess
  • afterRead
  • afterWrite
  • beforeProcess
  • beforeRead
  • beforeWrite
  • onReadError
  • onSkipInProcess
  • onSkipInRead
  • onWriteError
  • register
    Register the listener for callbacks on the appropriate interfaces implemented. Any StepListener can
  • onProcessError
  • register,
  • onProcessError,
  • onRetryProcessException,
  • onRetryReadException,
  • onRetryWriteException,
  • getTargetException,
  • afterChunk,
  • afterStep,
  • beforeChunk

Popular in Java

  • Creating JSON documents from java classes using gson
  • getSharedPreferences (Context)
  • getResourceAsStream (ClassLoader)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • JComboBox (javax.swing)
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now