Tabnine Logo
BatchRetryTemplate.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
org.springframework.batch.core.step.item.BatchRetryTemplate
constructor

Best Java code snippets using org.springframework.batch.core.step.item.BatchRetryTemplate.<init> (Showing top 11 results out of 315)

origin: spring-projects/spring-batch

BatchRetryTemplate batchRetryTemplate = new BatchRetryTemplate();
if (backOffPolicy != null) {
  batchRetryTemplate.setBackOffPolicy(backOffPolicy);
origin: spring-projects/spring-batch

@Test
public void testSuccessfulAttempt() throws Exception {
  BatchRetryTemplate template = new BatchRetryTemplate();
  String result = template.execute(new RetryCallback<String, Exception>() {
    @Override
    public String doWithRetry(RetryContext context) throws Exception {
      assertTrue("Wrong context type: " + context.getClass().getSimpleName(), context.getClass()
          .getSimpleName().contains("Batch"));
      return "2";
    }
  }, Arrays.<RetryState> asList(new DefaultRetryState("1")));
  assertEquals("2", result);
}
origin: spring-projects/spring-batch

@Test(expected = ExhaustedRetryException.class)
public void testExhaustedRetry() throws Exception {
  BatchRetryTemplate template = new BatchRetryTemplate();
  template.setRetryPolicy(new SimpleRetryPolicy(1, Collections
      .<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
  RetryCallback<String[], Exception> retryCallback = new RetryCallback<String[], Exception>() {
    @Override
    public String[] doWithRetry(RetryContext context) throws Exception {
      if (count++ < 2) {
        throw new RecoverableException("Recoverable");
      }
      return outputs.toArray(new String[0]);
    }
  };
  outputs = Arrays.asList("a", "b");
  try {
    template.execute(retryCallback, BatchRetryTemplate.createState(outputs));
    fail("Expected RecoverableException");
  }
  catch (RecoverableException e) {
    assertEquals("Recoverable", e.getMessage());
  }
  outputs = Arrays.asList("a", "c");
  template.execute(retryCallback, BatchRetryTemplate.createState(outputs));
}
origin: spring-projects/spring-batch

@Test
public void testUnSuccessfulAttemptAndRetry() throws Exception {
  BatchRetryTemplate template = new BatchRetryTemplate();
  RetryCallback<String[], Exception> retryCallback = new RetryCallback<String[], Exception>() {
    @Override
    public String[] doWithRetry(RetryContext context) throws Exception {
      assertEquals(count, context.getRetryCount());
      if (count++ == 0) {
        throw new RecoverableException("Recoverable");
      }
      return new String[] { "a", "b" };
    }
  };
  List<RetryState> states = Arrays.<RetryState> asList(new DefaultRetryState("1"), new DefaultRetryState("2"));
  try {
    template.execute(retryCallback, states);
    fail("Expected RecoverableException");
  }
  catch (RecoverableException e) {
    assertEquals("Recoverable", e.getMessage());
  }
  String[] result = template.execute(retryCallback, states);
  assertEquals("[a, b]", Arrays.toString(result));
}
origin: spring-projects/spring-batch

@Test
public void testExhaustedRetryWithRecovery() throws Exception {
  BatchRetryTemplate template = new BatchRetryTemplate();
  template.setRetryPolicy(new SimpleRetryPolicy(1, Collections
      .<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
origin: spring-projects/spring-batch

@Before
public void setUp() {
  batchRetryTemplate = new BatchRetryTemplate();
  processor = new FaultTolerantChunkProcessor<>(
      new PassThroughItemProcessor<>(),
      new ItemWriter<String>() {
        @Override
        public void write(List<? extends String> items)
            throws Exception {
          if (items.contains("fail")) {
            throw new RuntimeException("Planned failure!");
          }
          list.addAll(items);
        }
      }, batchRetryTemplate);
  batchRetryTemplate.setRetryPolicy(new NeverRetryPolicy());
}
origin: spring-projects/spring-batch

@Test
public void testExhaustedRetryAfterShuffle() throws Exception {
  BatchRetryTemplate template = new BatchRetryTemplate();
  template.setRetryPolicy(new SimpleRetryPolicy(1, Collections
      .<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
origin: org.springframework.batch/spring-batch-core

BatchRetryTemplate batchRetryTemplate = new BatchRetryTemplate();
if (backOffPolicy != null) {
  batchRetryTemplate.setBackOffPolicy(backOffPolicy);
origin: org.springframework.batch.core/org.motechproject.org.springframework.batch.core

BatchRetryTemplate batchRetryTemplate = new BatchRetryTemplate();
if (backOffPolicy != null) {
  batchRetryTemplate.setBackOffPolicy(backOffPolicy);
origin: apache/servicemix-bundles

BatchRetryTemplate batchRetryTemplate = new BatchRetryTemplate();
if (backOffPolicy != null) {
  batchRetryTemplate.setBackOffPolicy(backOffPolicy);
origin: org.springframework.batch/org.springframework.batch.core

BatchRetryTemplate batchRetryTemplate = new BatchRetryTemplate();
if (backOffPolicy != null) {
  batchRetryTemplate.setBackOffPolicy(backOffPolicy);
org.springframework.batch.core.step.itemBatchRetryTemplate<init>

Popular methods of BatchRetryTemplate

  • createState
  • execute
  • setRetryPolicy
  • setBackOffPolicy
  • setListeners
  • setRetryContextCache
  • canRetry

Popular in Java

  • Creating JSON documents from java classes using gson
  • requestLocationUpdates (LocationManager)
  • addToBackStack (FragmentTransaction)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • Socket (java.net)
    Provides a client-side TCP socket.
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Top Vim plugins
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