org.springframework.retry.policy.TimeoutRetryPolicy Java Examples
The following examples show how to use
org.springframework.retry.policy.TimeoutRetryPolicy.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultRetryTemplateConverterTest.java From distributed-lock with MIT License | 6 votes |
private void assertRetryTemplateConstruction(final RetryTemplate retryTemplate, final long timeout, final long backOff) { final var wrapper = PropertyAccessorFactory.forDirectFieldAccess(retryTemplate); assertThat(wrapper.getPropertyValue("retryPolicy")).isInstanceOf(CompositeRetryPolicy.class); assertThat((RetryPolicy[]) wrapper.getPropertyValue("retryPolicy.policies")) .hasSize(2) .anyMatch(policy1 -> { if (policy1 instanceof TimeoutRetryPolicy) { final var timeoutRetryPolicy = (TimeoutRetryPolicy) policy1; assertThat(timeoutRetryPolicy.getTimeout()).isEqualTo(timeout); return true; } return false; }) .anyMatch(policy2 -> { if (policy2 instanceof SimpleRetryPolicy) { final var simpleRetryPolicy = (SimpleRetryPolicy) policy2; assertThat(simpleRetryPolicy.getMaxAttempts()).isEqualTo(Integer.MAX_VALUE); return true; } return false; }); assertThat(wrapper.getPropertyValue("backOffPolicy")).isInstanceOf(FixedBackOffPolicy.class); assertThat(((FixedBackOffPolicy) wrapper.getPropertyValue("backOffPolicy")).getBackOffPeriod()).isEqualTo(backOff); }
Example #2
Source File: WebserviceDocumentItemProcessor.java From CogStack-Pipeline with Apache License 2.0 | 5 votes |
private RetryTemplate getRetryTemplate(){ TimeoutRetryPolicy retryPolicy = new TimeoutRetryPolicy(); retryPolicy.setTimeout(retryTimeoutMs); FixedBackOffPolicy backOffPolicy = new FixedBackOffPolicy(); backOffPolicy.setBackOffPeriod(retryBackoffMs); RetryTemplate template = new RetryTemplate(); template.setRetryPolicy(retryPolicy); template.setBackOffPolicy(backOffPolicy); return template; }
Example #3
Source File: ConnectionRetryConfig.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Bean public RetryPolicy retryPolicy() { TimeoutRetryPolicy timeoutRetryPolicy = new TimeoutRetryPolicy(); timeoutRetryPolicy.setTimeout(MAX_CONNECTION_TIMEOUT.toMillis()); ExceptionClassifierRetryPolicy exceptionClassifierRetryPolicy = new ExceptionClassifierRetryPolicy(); exceptionClassifierRetryPolicy.setPolicyMap( ImmutableMap.of(MolgenisDataException.class, timeoutRetryPolicy)); return exceptionClassifierRetryPolicy; }
Example #4
Source File: DefaultRetryTemplateConverter.java From distributed-lock with MIT License | 4 votes |
private RetryPolicy resolveTimeoutRetryPolicy(final Locked locked) { final var timeoutRetryPolicy = new TimeoutRetryPolicy(); timeoutRetryPolicy.setTimeout(intervalConverter.toMillis(locked.timeout())); return timeoutRetryPolicy; }