Commit Graph

74 Commits

Author SHA1 Message Date
Gary Russell
3726eef3ba Support Raw Keys
If the key generator is guaranteed to provide a unique key, it can be used as
the cache key directly.

Add a setter to support this option.
2016-10-12 20:19:18 +01:00
Dave Syer
507c62bdae Clarify javadocs in ExponentialRandomBackOffPolicy 2016-10-12 12:44:14 +02:00
Dave Syer
da5334fdf4 Merge branch '1.1.x' 2016-10-12 12:28:15 +02:00
Gary Russell
5a4f4c6a6a GH-56: Add Retry All Except... Option
Resolves: #56
2016-10-12 12:27:45 +02:00
Dave Syer
106398d284 Merge branch '1.1.x' 2016-10-12 12:06:34 +02:00
Dave Syer
23f2a35958 Add a sleep to try and avoid sporadic fails 2016-10-12 12:06:04 +02:00
Dave Syer
62edc287ca Merge branch '1.1.x' 2016-09-26 10:56:12 +01:00
Dave Syer
b3c3f50e9e Add equals() implementation to custom Pointcut
Also added test case from SPR-14702 (which now passes).

Fixes gh-53.
2016-09-26 10:54:54 +01:00
Dave Syer
e6a83c0556 Polish 2016-09-26 10:10:52 +01:00
Gary Russell
2e293c33c3 Set RetryState Key to null if Necessary
See 9a95da2b70

If the key generator returns null, we need to set the key to null so the
state is not stored.
2016-09-26 10:05:31 +01:00
Dave Syer
18705bd905 Add convenience constructor to SimpleRetryPolicy 2016-09-26 10:04:08 +01:00
Dave Syer
48935e745e Clarify contract of context cache 2016-09-23 16:12:59 +01:00
Dave Syer
9a95da2b70 If retry state key is null, context is not cached
If the retry state has a null key it could be an error, but there
are real work scenarios where that just means "no information"
and the safest thing to do in that case is to simply not cache the
retry context (so the retry callback is executed "naturally" and
the exception bubbles up).

See comment in gh-49 about Spring AMQP use case
2016-09-23 16:08:56 +01:00
Gary Russell
ce3621ea1d Find @Retryable on Target Class
fixes #32
2016-09-20 14:13:58 +01:00
Gary Russell
660c01adc9 GH-19 SimpleRetryPolicy MaxAttempts JavaDocs
See GH-19
2016-09-20 14:13:53 +01:00
Dave Syer
54f667f5be Chasing test coverage 2016-08-24 15:57:53 +01:00
Dave Syer
7aedbefc48 Extract constants and fix spelling error in their value 2016-08-24 15:07:04 +01:00
Dave Syer
0afcf3965d Add support for rolling averages and attributes in RetryStatistics
Using these you can get a pretty decent (if basic) hystrix-compatible
metrics stream. The "open" state of the circuit is exposed as
a RetryContext attribute for that purpose.
2016-08-24 10:32:41 +01:00
Dave Syer
9834a08020 Switch defaults of open and reset timeouts 2016-08-23 17:19:07 +01:00
Dave Syer
6c4d279546 Ensure label is used if available in stateful retry interceptor 2016-08-23 15:36:22 +01:00
Dave Syer
e99c32d40c Always cache the context if it is global
Circuit breakers, for instance, would like to store some state
for the duration of the lifetime of the circuit. So the normal
rule that the cache is not used until there is an error doesn't
make as much sense.
2016-08-23 15:07:18 +01:00
Dave Syer
38316963c1 Ensure label is only set if explicit 2016-08-23 13:31:00 +01:00
Dave Syer
411d47d7b2 Change the strategy for key generation in stateful retry
There were a couple of issues to fix here. The first was that only
the method arguments and not the method signature (or label) were
being used in the key generator. Plus the arguments were being
used as an array, which has a different hashcode on each invocation
(a Collection would be better). Plus the interceptor builder
didn't set the key generator in a circuit breaker, so all the method
calls with different args are unique and they are supposed to be the
same.

See gh-49
2016-08-23 12:29:48 +01:00
Dave Syer
08cb981f58 Add test for @CircuitBreaker and statistics 2016-08-23 11:45:20 +01:00
Dave Syer
a256349954 Add support for label in @Retryable
and test for it in RetryOperationsInterceptor
2016-08-23 11:21:28 +01:00
Dave Syer
f3e1c4675d Check for null listeners 2016-08-23 11:00:26 +01:00
Dave Syer
5a70f99738 Line endings 2016-08-23 10:57:56 +01:00
Dave Syer
730d93038c Ensure label is used in StatefulRetryOperationsInterceptor 2016-08-23 10:57:56 +01:00
Dave Syer
1cb4f19cf1 Add support for RetryListener beans in @EnableRetry 2016-08-23 10:57:56 +01:00
Dave Syer
cc97238158 Consolidate calls to parent.open() 2016-08-23 10:57:56 +01:00
Dave Syer
f47584812b Basic integration between statistics and circuit breaker
Really just a check that the existing metrics make sense. Next
step is to provide statistics for each circuit including
information on circuit status and timeouts.
2016-08-23 10:57:56 +01:00
Dave Syer
9af84c086d Initial working draft of circuit breaker retry policy
User can manually configure a CircuitBreakerRetryPolicy
but needs to be careful to use stateful retry and
a RetryState where rollbackFor() is always false so that the
recovery is applied.

Better (probably) is to use @CircuitBreaker.
2016-08-23 10:57:56 +01:00
Gary Russell
51523c0b40 Find @Retryable on Target Class
fixes #32
2016-08-23 10:56:03 +01:00
Gary Russell
5e31f49e07 GH-19 SimpleRetryPolicy MaxAttempts JavaDocs
See GH-19
2016-08-23 10:52:04 +01:00
Dave Syer
c8f2d07adb Clarify rethrowing of original exception in RetryTemplate 2016-08-23 10:38:12 +01:00
Dave Syer
6c2cc11264 Add statistics support via a listener 2016-06-21 12:29:37 +01:00
Dave Syer
8fcd854365 Add a label to RetryContext 2016-06-21 12:29:37 +01:00
Dave Syer
419f16274a Rethrow original exception even if exhausted only
There doesn't seem to be much justification for throwing
RetryExhaustedException unconditionally when the context
is marked as exhausted. It would be better to behave,
as far as the caller is concerned, as if the cause had
been the original exception.
2016-04-12 07:24:22 -04:00
Josh Long
8c247151c9 support private @Recover methods 2016-02-12 17:50:20 +00:00
Josh Long
004d277c81 javadoc 2016-02-12 17:12:40 +01:00
Dave Syer
cacf5d25db Fix another typo 2016-02-10 09:38:23 +00:00
Dave Syer
c1ad693825 Tidy up some javadocs 2016-02-10 09:34:21 +00:00
Dave Syer
55839cefbb Widen Pointcut for @Retryable to cover multiple methods on same class
Fixes gh-15
2014-09-19 10:24:54 +01:00
Dave Syer
ff27754e74 Remove unused local variable 2014-09-19 09:33:52 +01:00
Dave Syer
e2bee41f02 Spelling mistake 2014-09-19 09:22:35 +01:00
Dave Syer
bdc4025250 Fixes gh-12: correct Javadocs
The method signature for RetryCallback was changed in 1.1 but the
Javadocs in RetryTemplate still reflected the old behaviour.
2014-08-22 16:16:18 +01:00
Artem Bilan
20d703410a Fix @EnableRetry do not proxy all beans
Fixes https://github.com/spring-projects/spring-retry/issues/13

Previously the `@EnableRetry` caused to proxy **all** beans in the context, because
of `IntroductionAdvisor` nature in the `AopUtils` logic and simple `ClassFilter.TRUE`
in that case. In the end it just skipped `MethodMatcher` and applied `ProxyFactory` for any bean.

Since we can't avoid `IntroductionAdvisor` because of `getInterfaces()` introduction,
provide a new internal `AnnotationClassOrMethodFilter` to apply both class and method level annotation filter at once.

Polishing for the `AnnotationAwareRetryOperationsInterceptor` to skip non-`@Retryable` methods and just call `invocation.proceed()`

Fixes gh-13, fixes gh-14
2014-08-22 16:02:44 +01:00
Artem Bilan
f9e53099bd Add RetryInterceptorBuilder support
* Add `RetryInterceptorBuilder` and its tests
* Add usage from `AnnotationAwareRetryOperationsInterceptor`
* Add `Retryable#interceptor()` option to use full Retry Interceptor from `BeanFactory`
* Fix `RetryConfiguration` `beanFactory` propagation

Fixes gh-11
2014-05-12 17:08:11 +01:00
Artem Bilan
1a54a3e1c2 Code Cleanup
* Deprecate `ObjectWaitSleeper` and replace it with `ThreadWaitSleeper`
* Improve `SimpleMethodInvoker`
* Use `if (logger.isDebugEnabled())` for better performance

The `RetryTemplate` continues to invoke `canRetry(retryPolicy, context)` with retry loop, because some end application may rely on that logic.
Although it looks like overhead to call `canRetry()` twice a retry: it might be heavy operation, e.g. check the state of external system

Fixes gh-10
2014-05-12 17:05:58 +01:00
Dave Syer
6b69ad901b Add proxyTargetClass attribute to @EnableRetry 2014-05-07 05:49:43 -07:00