File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
core/src/test/java/org/sterl/spring/persistent_tasks/scheduler Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 22
33import static org .assertj .core .api .Assertions .assertThat ;
44
5+ import java .time .temporal .ChronoUnit ;
56import java .util .concurrent .ExecutionException ;
67import java .util .concurrent .atomic .AtomicBoolean ;
78
1314import org .springframework .transaction .annotation .Transactional ;
1415import org .sterl .spring .persistent_tasks .AbstractSpringTest ;
1516import org .sterl .spring .persistent_tasks .api .RetryStrategy ;
17+ import org .sterl .spring .persistent_tasks .api .RetryStrategy .MultiplicativeRetryStrategy ;
1618import org .sterl .spring .persistent_tasks .api .SpringBeanTask ;
1719import org .sterl .spring .persistent_tasks .api .TaskId .TaskTriggerBuilder ;
1820import org .sterl .spring .persistent_tasks .api .TriggerKey ;
You can’t perform that action at this time.
0 commit comments