Package org.springframework.batch.repeat.policy

Examples of org.springframework.batch.repeat.policy.SimpleCompletionPolicy


        list.add("chain");
        return invocation.proceed();
      }
    });
    RepeatTemplate template = new RepeatTemplate();
    template.setCompletionPolicy(new SimpleCompletionPolicy(2));
    interceptor.setRepeatOperations(template);
    service.service();
    assertEquals(2, target.count);
    assertEquals(2, list.size());
  }
View Full Code Here


  // @Override
  public RepeatTemplate getRepeatTemplate() {
    TaskExecutorRepeatTemplate template = new TaskExecutorRepeatTemplate();
    template.setTaskExecutor(new SimpleAsyncTaskExecutor());
    // Set default completion above number of items in input file
    template.setCompletionPolicy(new SimpleCompletionPolicy(8));
    return template;
  }
View Full Code Here

  @Test
  public void testEarlyCompletionWithException() throws Exception {

    TaskExecutorRepeatTemplate template = new TaskExecutorRepeatTemplate();
    SimpleAsyncTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor();
    template.setCompletionPolicy(new SimpleCompletionPolicy(20));
    taskExecutor.setConcurrencyLimit(2);
    template.setTaskExecutor(taskExecutor);
    try {
      template.iterate(new RepeatCallback() {
                @Override
View Full Code Here

  @Test
  public void testExceptionHandlerSwallowsException() throws Exception {

    TaskExecutorRepeatTemplate template = new TaskExecutorRepeatTemplate();
    SimpleAsyncTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor();
    template.setCompletionPolicy(new SimpleCompletionPolicy(4));
    taskExecutor.setConcurrencyLimit(2);
    template.setTaskExecutor(taskExecutor);

    template.setExceptionHandler(new ExceptionHandler() {
            @Override
View Full Code Here

  BatchMessageListenerContainer container;

  @Test
  public void testReceiveAndExecuteWithCallback() throws Exception {
    RepeatTemplate template = new RepeatTemplate();
    template.setCompletionPolicy(new SimpleCompletionPolicy(2));
    container = getContainer(template);

    container.setMessageListener(new MessageListener() {
      @Override
      public void onMessage(Message arg0) {
View Full Code Here

  }

  @Test
  public void testReceiveAndExecuteWithCallbackReturningNull() throws Exception {
    RepeatTemplate template = new RepeatTemplate();
    template.setCompletionPolicy(new SimpleCompletionPolicy(2));
    container = getContainer(template);

    Session session = mock(Session.class);
    MessageConsumer consumer = mock(MessageConsumer.class);
    Message message = null;
View Full Code Here

  }

  @Test
  public void testTransactionalReceiveAndExecuteWithCallbackThrowingException() throws Exception {
    RepeatTemplate template = new RepeatTemplate();
    template.setCompletionPolicy(new SimpleCompletionPolicy(2));
    container = getContainer(template);
    container.setSessionTransacted(true);
    try {
      boolean received = doTestWithException(new IllegalStateException("No way!"), true, 2);
      assertFalse("Message received", received);
View Full Code Here

  }

  @Test
  public void testNonTransactionalReceiveAndExecuteWithCallbackThrowingException() throws Exception {
    RepeatTemplate template = new RepeatTemplate();
    template.setCompletionPolicy(new SimpleCompletionPolicy(2));
    container = getContainer(template);
    container.setSessionTransacted(false);
    boolean received = doTestWithException(new IllegalStateException("No way!"), false, 2);
    assertTrue("Message not received but listener not transactional so this should be true", received);
  }
View Full Code Here

  }

  @Test
  public void testNonTransactionalReceiveAndExecuteWithCallbackThrowingError() throws Exception {
    RepeatTemplate template = new RepeatTemplate();
    template.setCompletionPolicy(new SimpleCompletionPolicy(2));
    container = getContainer(template);
    container.setSessionTransacted(false);
    try {
      boolean received = doTestWithException(new RuntimeException("No way!"), false, 2);
      assertTrue("Message not received but listener not transactional so this should be true", received);
View Full Code Here

  @Test
  public void testThrottleLimitWithEarlyCompletion() throws Exception {

    early = 2;
    template.setCompletionPolicy(new SimpleCompletionPolicy(10));

    template.iterate(callback);
    int frequency = Collections.frequency(items, "null");
    assertEquals(10, items.size() - frequency);
    // System.err.println("Frequency: " + frequency);
View Full Code Here

TOP

Related Classes of org.springframework.batch.repeat.policy.SimpleCompletionPolicy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.