Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ ext {
rabbitmqVersion = '5.27.1'
reactorVersion = '2025.0.1-SNAPSHOT'
springDataVersion = '2025.1.0-SNAPSHOT'
springVersion = '7.0.0-RC1'
springVersion = '7.0.0-SNAPSHOT'
testcontainersVersion = '2.0.1'

javaProjects = subprojects - project(':spring-amqp-bom')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* <pre class="code">
* StatefulRetryOperationsInterceptor interceptor =
* RetryInterceptorBuilder.stateful()
* .maxAttempts(5)
* .maxRetries(5)
* .backOffOptions(1, 2, 10) // initialInterval, multiplier, maxInterval
* .build();
* </pre>
Expand Down Expand Up @@ -127,13 +127,13 @@ public B configureRetryPolicy(Consumer<RetryPolicy.Builder> retryPolicy) {
}

/**
* Apply the max attempts - a SimpleRetryPolicy will be used. Cannot be used if a custom retry operations
* Apply the max retries - a SimpleRetryPolicy will be used. Cannot be used if a custom retry operations
* or retry policy has been set.
* @param maxAttempts the max attempts.
* @param maxRetries the maximum number of retry attempts..
* @return this.
*/
public B maxAttempts(int maxAttempts) {
return configureRetryPolicy((retryPolicy) -> retryPolicy.maxAttempts(maxAttempts));
public B maxRetries(int maxRetries) {
return configureRetryPolicy((retryPolicy) -> retryPolicy.maxRetries(maxRetries));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public class RabbitAdmin implements AmqpAdmin, ApplicationContextAware, Applicat

private static final String UNUSED = "unused";

private static final int DECLARE_MAX_ATTEMPTS = 5;
private static final int DECLARE_MAX_RETRIES = 5;

private static final Duration DECLARE_INITIAL_RETRY_DELAY = Duration.ofSeconds(1);

Expand Down Expand Up @@ -597,7 +597,7 @@ public void afterPropertiesSet() {
if (this.retryTemplate == null && !this.retryDisabled) {
RetryPolicy retryPolicy =
RetryPolicy.builder()
.maxAttempts(DECLARE_MAX_ATTEMPTS)
.maxRetries(DECLARE_MAX_RETRIES)
.delay(DECLARE_INITIAL_RETRY_DELAY)
.multiplier(DECLARE_RETRY_MULTIPLIER)
.maxDelay(DECLARE_MAX_RETRY_DELAY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ private void startSenders() {
}
}
else if (this.manager.maxSenderRetries > 0) {
this.rabbitTemplate.setRetryTemplate(new RetryTemplate(RetryPolicy.withMaxAttempts(2)));
this.rabbitTemplate.setRetryTemplate(new RetryTemplate(RetryPolicy.withMaxRetries(2)));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void testBasic() {

@Test
public void testWithCustomRetryPolicy() {
RetryPolicy retryPolicy = RetryPolicy.builder().maxAttempts(2).build();
RetryPolicy retryPolicy = RetryPolicy.builder().maxRetries(2).build();
StatefulRetryOperationsInterceptor interceptor = RetryInterceptorBuilder.stateful()
.retryPolicy(retryPolicy)
.build();
Expand All @@ -78,7 +78,7 @@ public void testWithCustomRetryPolicy() {
public void testWithMoreAttempts() {
StatefulRetryOperationsInterceptor interceptor =
RetryInterceptorBuilder.stateful()
.maxAttempts(5)
.maxRetries(5)
.build();

assertThat(TestUtils.getPropertyValue(interceptor, "retryPolicy.backOff.maxAttempts")).isEqualTo(5L);
Expand All @@ -88,7 +88,7 @@ public void testWithMoreAttempts() {
public void testWithCustomizedBackOffMoreAttempts() {
StatefulRetryOperationsInterceptor interceptor =
RetryInterceptorBuilder.stateful()
.maxAttempts(5)
.maxRetries(5)
.backOffOptions(1, 2, 10)
.build();

Expand Down Expand Up @@ -149,7 +149,7 @@ public void testWithCustomNewMessageIdentifier() throws Exception {
@Test
public void testWitCustomRetryPolicyTraverseCause() {
StatefulRetryOperationsInterceptor interceptor = RetryInterceptorBuilder.stateful()
.retryPolicy(RetryPolicy.builder().maxAttempts(15).build())
.retryPolicy(RetryPolicy.builder().maxRetries(15).build())
.build();

assertThat(TestUtils.getPropertyValue(interceptor, "retryPolicy.backOff.maxAttempts")).isEqualTo(15L);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void invokeWithSuccessOnFirstInvocation() throws Throwable {

@Test
void invokeWithFailuresNotExhaustingRetries() throws Throwable {
RetryPolicy retryPolicy = RetryPolicy.builder().maxAttempts(2).delay(Duration.ZERO).build();
RetryPolicy retryPolicy = RetryPolicy.builder().maxRetries(2).delay(Duration.ZERO).build();
MethodInvocation invocation = mock(MethodInvocation.class);
given(invocation.proceed()).willThrow(new IllegalStateException("initial"))
.willThrow(new IllegalStateException("retry-1")).willReturn("hello");
Expand All @@ -66,7 +66,7 @@ void invokeWithFailuresNotExhaustingRetries() throws Throwable {

@Test
void invokeWithFailuresExhaustingRetriesReturnsResultFromRecoverer() throws Throwable {
RetryPolicy retryPolicy = RetryPolicy.builder().maxAttempts(2).delay(Duration.ZERO).build();
RetryPolicy retryPolicy = RetryPolicy.builder().maxRetries(2).delay(Duration.ZERO).build();
Exception lastException = new IllegalStateException("retry-2");
Object[] arguments = new Object[] { "message" };
MethodInvocation invocation = mock(MethodInvocation.class);
Expand All @@ -82,7 +82,7 @@ void invokeWithFailuresExhaustingRetriesReturnsResultFromRecoverer() throws Thro

@Test
void invokeWithFailuresExhaustingRetriesThrowsResultFromRecoverer() throws Throwable {
RetryPolicy retryPolicy = RetryPolicy.builder().maxAttempts(2).delay(Duration.ZERO).build();
RetryPolicy retryPolicy = RetryPolicy.builder().maxRetries(2).delay(Duration.ZERO).build();
Exception recovererException = new IllegalStateException("failed");
Object[] arguments = new Object[] { "message" };
MethodInvocation invocation = mock(MethodInvocation.class);
Expand All @@ -97,7 +97,7 @@ void invokeWithFailuresExhaustingRetriesThrowsResultFromRecoverer() throws Throw

@Test
void invokeWithFailuresExhaustingRetriesAndNoRecovererThrowsLastException() throws Throwable {
RetryPolicy retryPolicy = RetryPolicy.builder().maxAttempts(2).delay(Duration.ZERO).build();
RetryPolicy retryPolicy = RetryPolicy.builder().maxRetries(2).delay(Duration.ZERO).build();
Exception LastException = new IllegalStateException("retry-2");
Object[] arguments = new Object[] { "message" };
MethodInvocation invocation = mock(MethodInvocation.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public void testRetry() throws Exception {
CachingConnectionFactory ccf = new CachingConnectionFactory(rabbitConnectionFactory);
RabbitAdmin admin = new RabbitAdmin(ccf);
RetryTemplate rtt = new RetryTemplate();
rtt.setRetryPolicy(RetryPolicy.builder().maxAttempts(2).delay(Duration.ZERO).build());
rtt.setRetryPolicy(RetryPolicy.builder().maxRetries(2).delay(Duration.ZERO).build());
admin.setRetryTemplate(rtt);
GenericApplicationContext ctx = new GenericApplicationContext();
ctx.getBeanFactory().registerSingleton("foo", new AnonymousQueue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public void testRetry() throws Exception {
SingleConnectionFactory connectionFactory = new SingleConnectionFactory(mockConnectionFactory);
connectionFactory.setExecutor(mock(ExecutorService.class));
RabbitTemplate template = new RabbitTemplate(connectionFactory);
template.setRetryTemplate(new RetryTemplate(RetryPolicy.builder().maxAttempts(3).delay(Duration.ZERO).build()));
template.setRetryTemplate(new RetryTemplate(RetryPolicy.builder().maxRetries(3).delay(Duration.ZERO).build()));
try {
template.convertAndSend("foo", "bar", "baz");
}
Expand Down Expand Up @@ -295,7 +295,7 @@ public void testRecovery() throws Exception {
SingleConnectionFactory connectionFactory = new SingleConnectionFactory(mockConnectionFactory);
connectionFactory.setExecutor(mock(ExecutorService.class));
RabbitTemplate template = new RabbitTemplate(connectionFactory);
template.setRetryTemplate(new RetryTemplate(RetryPolicy.builder().maxAttempts(3).delay(Duration.ZERO).build()));
template.setRetryTemplate(new RetryTemplate(RetryPolicy.builder().maxRetries(3).delay(Duration.ZERO).build()));

final AtomicBoolean recoverInvoked = new AtomicBoolean();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ private Advice createRetryInterceptor(final CountDownLatch latch, boolean statef
latch.countDown();
});
}
factory.setRetryPolicy(RetryPolicy.builder().maxAttempts(2).delay(Duration.ofMillis(100)).build());
factory.setRetryPolicy(RetryPolicy.builder().maxRetries(2).delay(Duration.ofMillis(100)).build());
return factory.getObject();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public void testReplyRetry() throws Exception {
this.adapter = new MessageListenerAdapter();
this.adapter.setDefaultListenerMethod("handle");
this.adapter.setDelegate(this.simpleService);
RetryPolicy retryPolicy = RetryPolicy.builder().maxAttempts(2).delay(Duration.ZERO).build();
RetryPolicy retryPolicy = RetryPolicy.builder().maxRetries(2).delay(Duration.ZERO).build();
RetryTemplate retryTemplate = new RetryTemplate();
retryTemplate.setRetryPolicy(retryPolicy);
this.adapter.setRetryTemplate(retryTemplate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void testWithNoId() throws Exception {
@Test
public void testWithId() throws Exception {
// 2 messages; each retried twice by retry interceptor
RetryPolicy retryPolicy = RetryPolicy.builder().maxAttempts(2).delay(Duration.ZERO).build();
RetryPolicy retryPolicy = RetryPolicy.builder().maxRetries(2).delay(Duration.ZERO).build();
this.latch = new CountDownLatch(6);
ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext("retry-context.xml", this.getClass());
RabbitTemplate template = ctx.getBean(RabbitTemplate.class);
Expand Down Expand Up @@ -146,7 +146,7 @@ public void testWithId() throws Exception {

@Test
public void testWithIdAndSuccess() throws Exception {
RetryPolicy retryPolicy = RetryPolicy.builder().maxAttempts(2).delay(Duration.ZERO).build();
RetryPolicy retryPolicy = RetryPolicy.builder().maxRetries(2).delay(Duration.ZERO).build();
// 2 messages; each retried twice by retry interceptor
this.latch = new CountDownLatch(6);
ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext("retry-context.xml", this.getClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ The following example shows how to do so:
@Bean
public StatefulRetryOperationsInterceptor interceptor() {
return RetryInterceptorBuilder.stateful()
.maxAttempts(5)
.maxRetries(5)
.backOffOptions(1000, 2.0, 10000) // initialInterval, multiplier, maxInterval
.build();
}
Expand Down Expand Up @@ -151,7 +151,7 @@ The following example shows how to set a `RepublishMessageRecoverer` as the reco
@Bean
RetryOperationsInterceptor interceptor() {
return RetryInterceptorBuilder.stateless()
.maxAttempts(5)
.maxRetries(5)
.recoverer(new RepublishMessageRecoverer(amqpTemplate(), "something", "somethingelse"))
.build();
}
Expand Down