Skip to content

Commit 75f49ea

Browse files
committed
extended javadoc
1 parent abb46d9 commit 75f49ea

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,25 @@ public class BuildVehicleTask implements SpringBeanTask<Vehicle> {
6666

6767
private final VehicleRepository vehicleRepository;
6868

69-
@Transactional(timeout = 5)
7069
@Override
7170
public void accept(Vehicle vehicle) {
7271
// do stuff
7372
// save
7473
vehicleRepository.save(vehicle);
7574
}
75+
// OPTIONAL
76+
@Override
77+
public RetryStrategy retryStrategy() {
78+
// run 5 times, multiply the execution count with 4, add the result in HOURS to now.
79+
return new MultiplicativeRetryStrategy(5, ChronoUnit.HOURS, 4)
80+
}
81+
// OPTIONAL
82+
// if the task in accept requires a DB transaction, join them together with the framework
83+
// if true the TransactionTemplate is used. Set here any timeouts.
84+
@Override
85+
public boolean isTransactional() {
86+
return true;
87+
}
7688
}
7789
```
7890

core/src/test/java/org/sterl/spring/persistent_tasks/scheduler/SchedulerServiceTransactionTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static org.assertj.core.api.Assertions.assertThat;
44

5+
import java.time.temporal.ChronoUnit;
56
import java.util.concurrent.ExecutionException;
67
import java.util.concurrent.atomic.AtomicBoolean;
78

@@ -13,6 +14,7 @@
1314
import org.springframework.transaction.annotation.Transactional;
1415
import org.sterl.spring.persistent_tasks.AbstractSpringTest;
1516
import org.sterl.spring.persistent_tasks.api.RetryStrategy;
17+
import org.sterl.spring.persistent_tasks.api.RetryStrategy.MultiplicativeRetryStrategy;
1618
import org.sterl.spring.persistent_tasks.api.SpringBeanTask;
1719
import org.sterl.spring.persistent_tasks.api.TaskId.TaskTriggerBuilder;
1820
import org.sterl.spring.persistent_tasks.api.TriggerKey;

0 commit comments

Comments
 (0)