|
16 | 16 | */ |
17 | 17 | package org.apache.camel.component.springrabbit; |
18 | 18 |
|
| 19 | +import java.time.Duration; |
| 20 | + |
19 | 21 | import org.springframework.amqp.core.AmqpAdmin; |
20 | 22 | import org.springframework.amqp.rabbit.config.RetryInterceptorBuilder; |
21 | 23 | import org.springframework.amqp.rabbit.core.RabbitAdmin; |
@@ -69,17 +71,22 @@ public AbstractMessageListenerContainer createListenerContainer(SpringRabbitMQEn |
69 | 71 | listener.setAdviceChain(endpoint.getRetry()); |
70 | 72 | } else { |
71 | 73 | RetryInterceptorBuilder<?, ?> builder = RetryInterceptorBuilder.stateless(); |
| 74 | + RetryPolicy.Builder retryPolicyBuilder = RetryPolicy.builder(); |
| 75 | + |
72 | 76 | if (endpoint.getMaximumRetryAttempts() <= 0) { |
73 | | - builder.retryPolicy(RetryPolicy.withMaxRetries(0)); |
| 77 | + retryPolicyBuilder.maxRetries(0); |
74 | 78 | } else if (endpoint.getMaximumRetryAttempts() > 0) { |
75 | | - builder.retryPolicy(RetryPolicy.withMaxRetries(endpoint.getMaximumRetryAttempts())); |
| 79 | + retryPolicyBuilder.maxRetries(endpoint.getMaximumRetryAttempts()); |
76 | 80 | } |
77 | 81 | if (endpoint.getRetryDelay() > 0) { |
78 | | - builder.backOffOptions(endpoint.getRetryDelay(), 1, endpoint.getRetryDelay()); |
| 82 | + retryPolicyBuilder.delay(Duration.ofMillis(endpoint.getRetryDelay())); |
| 83 | + retryPolicyBuilder.multiplier(1); |
| 84 | + retryPolicyBuilder.maxDelay(Duration.ofMillis(endpoint.getRetryDelay())); |
79 | 85 | } |
80 | 86 | if (endpoint.isRejectAndDontRequeue()) { |
81 | 87 | builder.recoverer(new RejectAndDontRequeueRecoverer()); |
82 | 88 | } |
| 89 | + builder.retryPolicy(retryPolicyBuilder.build()); |
83 | 90 | listener.setAdviceChain(builder.build()); |
84 | 91 | } |
85 | 92 |
|
|
0 commit comments