use of org.apache.camel.processor.aggregate.OptimisticLockRetryPolicy in project camel by apache.
the class OptimisticLockRetryPolicyTest method testExponentialBackOffMaximumRetryDelay.
public void testExponentialBackOffMaximumRetryDelay() throws Exception {
OptimisticLockRetryPolicy policy = new OptimisticLockRetryPolicy();
policy.setRandomBackOff(false);
policy.setExponentialBackOff(true);
policy.setMaximumRetryDelay(200L);
policy.setRetryDelay(50L);
for (int i = 0; i < 10; i++) {
long elapsed = doDelay(policy, i);
switch(i) {
case 0:
assertDelay(50L, elapsed);
break;
case 1:
assertDelay(100L, elapsed);
break;
default:
assertDelay(200L, elapsed);
break;
}
}
}
use of org.apache.camel.processor.aggregate.OptimisticLockRetryPolicy in project camel by apache.
the class OptimisticLockRetryPolicyTest method testExponentialBackOff.
public void testExponentialBackOff() throws Exception {
OptimisticLockRetryPolicy policy = new OptimisticLockRetryPolicy();
policy.setRandomBackOff(false);
policy.setExponentialBackOff(true);
policy.setMaximumRetryDelay(0L);
policy.setRetryDelay(50L);
for (int i = 0; i < 6; i++) {
long elapsed = doDelay(policy, i);
assertDelay(50L << i, elapsed);
}
}
use of org.apache.camel.processor.aggregate.OptimisticLockRetryPolicy in project camel by apache.
the class OptimisticLockRetryPolicyTest method testMaximumRetries.
public void testMaximumRetries() throws Exception {
OptimisticLockRetryPolicy policy = new OptimisticLockRetryPolicy();
policy.setRandomBackOff(false);
policy.setExponentialBackOff(false);
policy.setMaximumRetryDelay(0L);
policy.setMaximumRetries(2);
policy.setRetryDelay(50L);
for (int i = 0; i < 10; i++) {
switch(i) {
case 0:
case 1:
assertTrue(policy.shouldRetry(i));
break;
default:
assertFalse(policy.shouldRetry(i));
}
}
}
use of org.apache.camel.processor.aggregate.OptimisticLockRetryPolicy in project camel by apache.
the class DistributedOptimisticLockFailingTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:fails").aggregate(header("id"), new BodyInAggregatingStrategy()).aggregationRepository(new AlwaysFailingRepository()).optimisticLocking().optimisticLockRetryPolicy(new OptimisticLockRetryPolicy().maximumRetries(5)).completionSize(2).to("mock:result");
from("direct:everysecondone").aggregate(header("id"), new BodyInAggregatingStrategy()).aggregationRepository(sharedRepository).optimisticLocking().completionSize(8).to("mock:result");
}
};
}
use of org.apache.camel.processor.aggregate.OptimisticLockRetryPolicy in project camel by apache.
the class OptimisticLockRetryPolicyTest method testRetryDelay.
public void testRetryDelay() throws Exception {
OptimisticLockRetryPolicy policy = new OptimisticLockRetryPolicy();
policy.setRandomBackOff(false);
policy.setExponentialBackOff(false);
policy.setMaximumRetryDelay(0L);
policy.setRetryDelay(50L);
for (int i = 0; i < 10; i++) {
long elapsed = doDelay(policy, i);
assertDelay(50L, elapsed);
}
}
Aggregations