Updated Spring Retry to 1.1.0.RC1
This commit is contained in:
@@ -39,7 +39,7 @@ allprojects {
|
||||
|
||||
springVersionDefault = '4.0.2.RELEASE'
|
||||
springVersion = project.hasProperty('springVersion') ? getProperty('springVersion') : springVersionDefault
|
||||
springRetryVersion = '1.0.3.RELEASE'
|
||||
springRetryVersion = '1.1.0.RC1'
|
||||
springAmqpVersion = '1.1.2.RELEASE'
|
||||
springDataCommonsVersion = '1.5.0.RELEASE'
|
||||
springDataGemfireVersion = '1.3.0.RELEASE'
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
*/
|
||||
package org.springframework.batch.core.jsr.step.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.batch.operations.BatchRuntimeException;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.batch.core.StepContribution;
|
||||
@@ -43,6 +40,9 @@ import org.springframework.retry.RetryContext;
|
||||
import org.springframework.retry.RetryException;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.batch.operations.BatchRuntimeException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Extension of the {@link JsrChunkProcessor} that adds skip and retry functionality.
|
||||
*
|
||||
@@ -97,7 +97,7 @@ public class JsrFaultTolerantChunkProcessor<I,O> extends JsrChunkProcessor<I, O>
|
||||
* Register some {@link StepListener}s with the handler. Each will get the
|
||||
* callbacks in the order specified at the correct stage.
|
||||
*
|
||||
* @param listeners
|
||||
* @param listeners listeners to be registered
|
||||
*/
|
||||
@Override
|
||||
public void setListeners(List<? extends StepListener> listeners) {
|
||||
@@ -126,7 +126,7 @@ public class JsrFaultTolerantChunkProcessor<I,O> extends JsrChunkProcessor<I, O>
|
||||
*/
|
||||
@Override
|
||||
protected I provide(final StepContribution contribution, final Chunk<I> chunk) throws Exception {
|
||||
RetryCallback<I> retryCallback = new RetryCallback<I>() {
|
||||
RetryCallback<I, Exception> retryCallback = new RetryCallback<I, Exception>() {
|
||||
|
||||
@Override
|
||||
public I doWithRetry(RetryContext arg0) throws Exception {
|
||||
@@ -217,11 +217,10 @@ public class JsrFaultTolerantChunkProcessor<I,O> extends JsrChunkProcessor<I, O>
|
||||
@SuppressWarnings("unchecked")
|
||||
protected O transform(final StepContribution contribution, final I item) throws Exception {
|
||||
if (!hasProcessor) {
|
||||
O result = (O) item;
|
||||
return result;
|
||||
return (O) item;
|
||||
}
|
||||
|
||||
RetryCallback<O> retryCallback = new RetryCallback<O>() {
|
||||
RetryCallback<O, Exception> retryCallback = new RetryCallback<O, Exception>() {
|
||||
|
||||
@Override
|
||||
public O doWithRetry(RetryContext context) throws Exception {
|
||||
@@ -289,7 +288,7 @@ public class JsrFaultTolerantChunkProcessor<I,O> extends JsrChunkProcessor<I, O>
|
||||
@Override
|
||||
protected void persist(final StepContribution contribution, final Chunk<O> chunk) throws Exception {
|
||||
|
||||
RetryCallback<Object> retryCallback = new RetryCallback<Object>() {
|
||||
RetryCallback<Object, Exception> retryCallback = new RetryCallback<Object, Exception>() {
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public Object doWithRetry(RetryContext context) throws Exception {
|
||||
|
||||
@@ -16,11 +16,6 @@
|
||||
|
||||
package org.springframework.batch.core.step.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.classify.Classifier;
|
||||
import org.springframework.retry.ExhaustedRetryException;
|
||||
import org.springframework.retry.RecoveryCallback;
|
||||
@@ -37,6 +32,11 @@ import org.springframework.retry.support.DefaultRetryState;
|
||||
import org.springframework.retry.support.RetrySynchronizationManager;
|
||||
import org.springframework.retry.support.RetryTemplate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A special purpose retry template that deals specifically with multi-valued
|
||||
* stateful retry. This is useful in the case where the operation to be retried
|
||||
@@ -153,13 +153,13 @@ public class BatchRetryTemplate implements RetryOperations {
|
||||
|
||||
@Override
|
||||
protected <T> T handleRetryExhausted(RecoveryCallback<T> recoveryCallback, RetryContext context,
|
||||
RetryState state) throws Exception {
|
||||
RetryState state) throws Throwable {
|
||||
|
||||
BatchRetryState batchState = (BatchRetryState) state;
|
||||
BatchRetryContext batchContext = (BatchRetryContext) context;
|
||||
|
||||
// Accumulate exceptions to be thrown so all the keys get a crack
|
||||
Exception rethrowable = null;
|
||||
Throwable rethrowable = null;
|
||||
ExhaustedRetryException exhausted = null;
|
||||
|
||||
Iterator<RetryContext> contextIterator = batchContext.contexts.iterator();
|
||||
@@ -173,7 +173,7 @@ public class BatchRetryTemplate implements RetryOperations {
|
||||
catch (ExhaustedRetryException e) {
|
||||
exhausted = e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (Throwable e) {
|
||||
rethrowable = e;
|
||||
}
|
||||
|
||||
@@ -199,37 +199,37 @@ public class BatchRetryTemplate implements RetryOperations {
|
||||
|
||||
private RetryPolicy retryPolicy;
|
||||
|
||||
public <T> T execute(RetryCallback<T> retryCallback, Collection<RetryState> states) throws ExhaustedRetryException,
|
||||
public <T, E extends Throwable> T execute(RetryCallback<T, E> retryCallback, Collection<RetryState> states) throws E,
|
||||
Exception {
|
||||
RetryState batchState = new BatchRetryState(states);
|
||||
return delegate.execute(retryCallback, batchState);
|
||||
}
|
||||
|
||||
public <T> T execute(RetryCallback<T> retryCallback, RecoveryCallback<T> recoveryCallback,
|
||||
Collection<RetryState> states) throws ExhaustedRetryException, Exception {
|
||||
public <T, E extends Throwable> T execute(RetryCallback<T, E> retryCallback, RecoveryCallback<T> recoveryCallback,
|
||||
Collection<RetryState> states) throws E, Exception {
|
||||
RetryState batchState = new BatchRetryState(states);
|
||||
return delegate.execute(retryCallback, recoveryCallback, batchState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <T> T execute(RetryCallback<T> retryCallback, RecoveryCallback<T> recoveryCallback,
|
||||
RetryState retryState) throws Exception, ExhaustedRetryException {
|
||||
public final <T, E extends Throwable> T execute(RetryCallback<T, E> retryCallback, RecoveryCallback<T> recoveryCallback,
|
||||
RetryState retryState) throws E {
|
||||
return regular.execute(retryCallback, recoveryCallback, retryState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <T> T execute(RetryCallback<T> retryCallback, RecoveryCallback<T> recoveryCallback) throws Exception {
|
||||
public final <T, E extends Throwable> T execute(RetryCallback<T, E> retryCallback, RecoveryCallback<T> recoveryCallback) throws E {
|
||||
return regular.execute(retryCallback, recoveryCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <T> T execute(RetryCallback<T> retryCallback, RetryState retryState) throws Exception,
|
||||
public final <T, E extends Throwable> T execute(RetryCallback<T, E> retryCallback, RetryState retryState) throws E,
|
||||
ExhaustedRetryException {
|
||||
return regular.execute(retryCallback, retryState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <T> T execute(RetryCallback<T> retryCallback) throws Exception {
|
||||
public final <T, E extends Throwable> T execute(RetryCallback<T, E> retryCallback) throws E {
|
||||
return regular.execute(retryCallback);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,13 +16,6 @@
|
||||
|
||||
package org.springframework.batch.core.step.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.batch.core.StepContribution;
|
||||
@@ -42,6 +35,13 @@ import org.springframework.retry.RetryContext;
|
||||
import org.springframework.retry.RetryException;
|
||||
import org.springframework.retry.support.DefaultRetryState;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/**
|
||||
* FaultTolerant implementation of the {@link ChunkProcessor} interface, that
|
||||
* allows for skipping or retry of items that cause exceptions during writing.
|
||||
@@ -96,14 +96,14 @@ public class FaultTolerantChunkProcessor<I, O> extends SimpleChunkProcessor<I, O
|
||||
* A classifier that can distinguish between exceptions that cause rollback
|
||||
* (return true) or not (return false).
|
||||
*
|
||||
* @param rollbackClassifier
|
||||
* @param rollbackClassifier classifier
|
||||
*/
|
||||
public void setRollbackClassifier(Classifier<Throwable, Boolean> rollbackClassifier) {
|
||||
this.rollbackClassifier = rollbackClassifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param chunkMonitor
|
||||
* @param chunkMonitor monitor
|
||||
*/
|
||||
public void setChunkMonitor(ChunkMonitor chunkMonitor) {
|
||||
this.chunkMonitor = chunkMonitor;
|
||||
@@ -115,7 +115,7 @@ public class FaultTolerantChunkProcessor<I, O> extends SimpleChunkProcessor<I, O
|
||||
* complicated because after a rollback the new chunk might or might not
|
||||
* contain items from the previous failed chunk.
|
||||
*
|
||||
* @param buffering
|
||||
* @param buffering true if items will be buffered
|
||||
*/
|
||||
public void setBuffering(boolean buffering) {
|
||||
this.buffering = buffering;
|
||||
@@ -210,7 +210,7 @@ public class FaultTolerantChunkProcessor<I, O> extends SimpleChunkProcessor<I, O
|
||||
|
||||
final I item = iterator.next();
|
||||
|
||||
RetryCallback<O> retryCallback = new RetryCallback<O>() {
|
||||
RetryCallback<O, Exception> retryCallback = new RetryCallback<O, Exception>() {
|
||||
|
||||
@Override
|
||||
public O doWithRetry(RetryContext context) throws Exception {
|
||||
@@ -317,7 +317,7 @@ public class FaultTolerantChunkProcessor<I, O> extends SimpleChunkProcessor<I, O
|
||||
final UserData<O> data = (UserData<O>) inputs.getUserData();
|
||||
final AtomicReference<RetryContext> contextHolder = new AtomicReference<RetryContext>();
|
||||
|
||||
RetryCallback<Object> retryCallback = new RetryCallback<Object>() {
|
||||
RetryCallback<Object, Exception> retryCallback = new RetryCallback<Object, Exception>() {
|
||||
@Override
|
||||
public Object doWithRetry(RetryContext context) throws Exception {
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.batch.core.step.item;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.batch.repeat.RepeatContext;
|
||||
@@ -28,6 +26,8 @@ import org.springframework.retry.RetryContext;
|
||||
import org.springframework.retry.RetryPolicy;
|
||||
import org.springframework.retry.listener.RetryListenerSupport;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* An {@link ExceptionHandler} that is aware of the retry context so that it can
|
||||
* distinguish between a fatal exception and one that can be retried. Delegates
|
||||
@@ -58,7 +58,7 @@ public class SimpleRetryExceptionHandler extends RetryListenerSupport implements
|
||||
* exception is encountered
|
||||
* @param exceptionHandler the delegate to use if an exception actually
|
||||
* needs to be handled
|
||||
* @param fatalExceptionClasses
|
||||
* @param fatalExceptionClasses exceptions
|
||||
*/
|
||||
public SimpleRetryExceptionHandler(RetryPolicy retryPolicy, ExceptionHandler exceptionHandler, Collection<Class<? extends Throwable>> fatalExceptionClasses) {
|
||||
this.retryPolicy = retryPolicy;
|
||||
@@ -95,7 +95,7 @@ public class SimpleRetryExceptionHandler extends RetryListenerSupport implements
|
||||
* org.springframework.retry.RetryCallback, java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
public <T> void close(RetryContext context, RetryCallback<T> callback, Throwable throwable) {
|
||||
public <T, E extends Throwable> void close(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) {
|
||||
if (!retryPolicy.canRetry(context)) {
|
||||
logger.debug("Marking retry as exhausted: "+context);
|
||||
getRepeatContext().setAttribute(EXHAUSTED, "true");
|
||||
|
||||
@@ -26,16 +26,16 @@ import org.springframework.retry.RetryListener;
|
||||
public class DummyRetryListener implements RetryListener {
|
||||
|
||||
@Override
|
||||
public <T> boolean open(RetryContext context, RetryCallback<T> callback) {
|
||||
public <T, E extends Throwable> boolean open(RetryContext context, RetryCallback<T, E> callback) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void close(RetryContext context, RetryCallback<T> callback, Throwable throwable) {
|
||||
public <T, E extends Throwable> void close(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void onError(RetryContext context, RetryCallback<T> callback, Throwable throwable) {
|
||||
public <T, E extends Throwable> void onError(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,17 +22,17 @@ import org.springframework.retry.RetryListener;
|
||||
public class TestRetryListener extends AbstractTestComponent implements RetryListener {
|
||||
|
||||
@Override
|
||||
public <T> void close(RetryContext context, RetryCallback<T> callback,
|
||||
public <T, E extends Throwable> void close(RetryContext context, RetryCallback<T, E> callback,
|
||||
Throwable throwable) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void onError(RetryContext context, RetryCallback<T> callback,
|
||||
public <T, E extends Throwable> void onError(RetryContext context, RetryCallback<T, E> callback,
|
||||
Throwable throwable) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> boolean open(RetryContext context, RetryCallback<T> callback) {
|
||||
public <T, E extends Throwable> boolean open(RetryContext context, RetryCallback<T, E> callback) {
|
||||
executed = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -15,15 +15,6 @@
|
||||
*/
|
||||
package org.springframework.batch.core.step.item;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.retry.ExhaustedRetryException;
|
||||
import org.springframework.retry.RecoveryCallback;
|
||||
@@ -33,6 +24,15 @@ import org.springframework.retry.RetryState;
|
||||
import org.springframework.retry.policy.SimpleRetryPolicy;
|
||||
import org.springframework.retry.support.DefaultRetryState;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class BatchRetryTemplateTests {
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@@ -53,7 +53,7 @@ public class BatchRetryTemplateTests {
|
||||
|
||||
BatchRetryTemplate template = new BatchRetryTemplate();
|
||||
|
||||
String result = template.execute(new RetryCallback<String>() {
|
||||
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()
|
||||
@@ -71,7 +71,7 @@ public class BatchRetryTemplateTests {
|
||||
|
||||
BatchRetryTemplate template = new BatchRetryTemplate();
|
||||
|
||||
RetryCallback<String[]> retryCallback = new RetryCallback<String[]>() {
|
||||
RetryCallback<String[], Exception> retryCallback = new RetryCallback<String[], Exception>() {
|
||||
@Override
|
||||
public String[] doWithRetry(RetryContext context) throws Exception {
|
||||
assertEquals(count, context.getRetryCount());
|
||||
@@ -103,7 +103,7 @@ public class BatchRetryTemplateTests {
|
||||
template.setRetryPolicy(new SimpleRetryPolicy(1, Collections
|
||||
.<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
|
||||
|
||||
RetryCallback<String[]> retryCallback = new RetryCallback<String[]>() {
|
||||
RetryCallback<String[], Exception> retryCallback = new RetryCallback<String[], Exception>() {
|
||||
@Override
|
||||
public String[] doWithRetry(RetryContext context) throws Exception {
|
||||
if (count++ < 2) {
|
||||
@@ -133,7 +133,7 @@ public class BatchRetryTemplateTests {
|
||||
template.setRetryPolicy(new SimpleRetryPolicy(1, Collections
|
||||
.<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
|
||||
|
||||
RetryCallback<String[]> retryCallback = new RetryCallback<String[]>() {
|
||||
RetryCallback<String[], Exception> retryCallback = new RetryCallback<String[], Exception>() {
|
||||
@Override
|
||||
public String[] doWithRetry(RetryContext context) throws Exception {
|
||||
if (count++ < 1) {
|
||||
@@ -188,7 +188,7 @@ public class BatchRetryTemplateTests {
|
||||
template.setRetryPolicy(new SimpleRetryPolicy(1, Collections
|
||||
.<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
|
||||
|
||||
RetryCallback<String[]> retryCallback = new RetryCallback<String[]>() {
|
||||
RetryCallback<String[], Exception> retryCallback = new RetryCallback<String[], Exception>() {
|
||||
@Override
|
||||
public String[] doWithRetry(RetryContext context) throws Exception {
|
||||
if (count++ < 2) {
|
||||
|
||||
@@ -15,36 +15,35 @@
|
||||
*/
|
||||
package org.springframework.batch.container.jms;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.jms.JMSException;
|
||||
import javax.jms.Message;
|
||||
import javax.jms.MessageListener;
|
||||
import javax.jms.TextMessage;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jms.core.JmsTemplate;
|
||||
import org.springframework.retry.RecoveryCallback;
|
||||
import org.springframework.retry.RetryCallback;
|
||||
import org.springframework.retry.RetryContext;
|
||||
import org.springframework.retry.policy.NeverRetryPolicy;
|
||||
import org.springframework.retry.support.DefaultRetryState;
|
||||
import org.springframework.retry.support.RetryTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jms.core.JmsTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import javax.jms.JMSException;
|
||||
import javax.jms.Message;
|
||||
import javax.jms.MessageListener;
|
||||
import javax.jms.TextMessage;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
@@ -137,7 +136,7 @@ public class BatchMessageListenerContainerIntegrationTests {
|
||||
@Override
|
||||
public void onMessage(final Message msg) {
|
||||
try {
|
||||
RetryCallback<Message> callback = new RetryCallback<Message>() {
|
||||
RetryCallback<Message, Exception> callback = new RetryCallback<Message, Exception>() {
|
||||
@Override
|
||||
public Message doWithRetry(RetryContext context) throws Exception {
|
||||
try {
|
||||
|
||||
@@ -16,14 +16,6 @@
|
||||
|
||||
package org.springframework.batch.jms;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -51,6 +43,13 @@ import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.support.TransactionCallback;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "/org/springframework/batch/jms/jms-context.xml")
|
||||
public class ExternalRetryInBatchTests {
|
||||
@@ -136,7 +135,7 @@ public class ExternalRetryInBatchTests {
|
||||
return RepeatStatus.FINISHED;
|
||||
}
|
||||
|
||||
RetryCallback<String> callback = new RetryCallback<String>() {
|
||||
RetryCallback<String, Exception> callback = new RetryCallback<String, Exception>() {
|
||||
@Override
|
||||
public String doWithRetry(RetryContext context) throws Exception {
|
||||
// No need for transaction here: the whole batch will roll
|
||||
|
||||
@@ -16,15 +16,6 @@
|
||||
|
||||
package org.springframework.batch.retry.jms;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -45,6 +36,14 @@ import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.support.TransactionCallback;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "/org/springframework/batch/jms/jms-context.xml")
|
||||
public class ExternalRetryTests {
|
||||
@@ -102,7 +101,7 @@ public class ExternalRetryTests {
|
||||
|
||||
final ItemWriter<Object> writer = new ItemWriter<Object>() {
|
||||
@Override
|
||||
public void write(final List<? extends Object> texts) {
|
||||
public void write(final List<?> texts) {
|
||||
|
||||
for (Object text : texts) {
|
||||
|
||||
@@ -123,7 +122,7 @@ public class ExternalRetryTests {
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
try {
|
||||
final Object item = provider.read();
|
||||
RetryCallback<Object> callback = new RetryCallback<Object>() {
|
||||
RetryCallback<Object, Exception> callback = new RetryCallback<Object, Exception>() {
|
||||
@Override
|
||||
public Object doWithRetry(RetryContext context) throws Exception {
|
||||
writer.write(Collections.singletonList(item));
|
||||
@@ -153,7 +152,7 @@ public class ExternalRetryTests {
|
||||
public Object doInTransaction(TransactionStatus status) {
|
||||
try {
|
||||
final String item = provider.read();
|
||||
RetryCallback<Object> callback = new RetryCallback<Object>() {
|
||||
RetryCallback<Object, Exception> callback = new RetryCallback<Object, Exception>() {
|
||||
@Override
|
||||
public Object doWithRetry(RetryContext context) throws Exception {
|
||||
writer.write(Collections.singletonList(item));
|
||||
@@ -187,7 +186,7 @@ public class ExternalRetryTests {
|
||||
assertInitialState();
|
||||
|
||||
final String item = provider.read();
|
||||
final RetryCallback<String> callback = new RetryCallback<String>() {
|
||||
final RetryCallback<String, Exception> callback = new RetryCallback<String, Exception>() {
|
||||
@Override
|
||||
public String doWithRetry(RetryContext context) throws Exception {
|
||||
jdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), item);
|
||||
|
||||
@@ -16,16 +16,6 @@
|
||||
|
||||
package org.springframework.batch.retry.jms;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -48,6 +38,15 @@ import org.springframework.transaction.support.TransactionCallback;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "/org/springframework/batch/jms/jms-context.xml")
|
||||
public class SynchronousTests {
|
||||
@@ -124,7 +123,7 @@ public class SynchronousTests {
|
||||
final String text = (String) jmsTemplate.receiveAndConvert("queue");
|
||||
assertNotNull(text);
|
||||
|
||||
retryTemplate.execute(new RetryCallback<String>() {
|
||||
retryTemplate.execute(new RetryCallback<String, Exception>() {
|
||||
@Override
|
||||
public String doWithRetry(RetryContext status) throws Exception {
|
||||
|
||||
@@ -176,7 +175,7 @@ public class SynchronousTests {
|
||||
|
||||
final String item = (String) provider.read();
|
||||
|
||||
retryTemplate.execute(new RetryCallback<String>() {
|
||||
retryTemplate.execute(new RetryCallback<String, Exception>() {
|
||||
@Override
|
||||
public String doWithRetry(RetryContext context) throws Exception {
|
||||
|
||||
@@ -240,7 +239,7 @@ public class SynchronousTests {
|
||||
final String text = (String) jmsTemplate.receiveAndConvert("queue");
|
||||
|
||||
try {
|
||||
retryTemplate.execute(new RetryCallback<String>() {
|
||||
retryTemplate.execute(new RetryCallback<String, Exception>() {
|
||||
@Override
|
||||
public String doWithRetry(RetryContext status) throws Exception {
|
||||
|
||||
@@ -297,7 +296,7 @@ public class SynchronousTests {
|
||||
|
||||
assertInitialState();
|
||||
|
||||
retryTemplate.execute(new RetryCallback<String>() {
|
||||
retryTemplate.execute(new RetryCallback<String, Exception>() {
|
||||
@Override
|
||||
public String doWithRetry(RetryContext status) throws Exception {
|
||||
|
||||
@@ -347,7 +346,7 @@ public class SynchronousTests {
|
||||
|
||||
try {
|
||||
|
||||
retryTemplate.execute(new RetryCallback<String>() {
|
||||
retryTemplate.execute(new RetryCallback<String, Exception>() {
|
||||
@Override
|
||||
public String doWithRetry(RetryContext status) throws Exception {
|
||||
|
||||
|
||||
@@ -715,7 +715,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.retry</groupId>
|
||||
<artifactId>spring-retry</artifactId>
|
||||
<version>1.0.3.RELEASE</version>
|
||||
<version>1.1.0.RC1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.amqp</groupId>
|
||||
|
||||
Reference in New Issue
Block a user