Skip to content

Commit 23e7afb

Browse files
chore: restore retry mechanism for message sending in RocketMQInboundChannelAdapter (#4162)
chore: restore retry mechanism for message sending in RocketMQInboundChannelAdapter (#4162)
1 parent 89436ae commit 23e7afb

7 files changed

Lines changed: 18 additions & 11 deletions

File tree

spring-cloud-alibaba-starters/spring-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/constants/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2023 the original author or authors.
2+
* Copyright 2013-present the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-cloud-alibaba-starters/spring-alibaba-nacos-config/src/test/java/com.alibaba.cloud.nacos/configdata/NacosConfigManagerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2023 the original author or authors.
2+
* Copyright 2013-present the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-seata/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616

1717
<!--spring boot-->
1818

19+
<dependency>
20+
<groupId>org.springframework.boot</groupId>
21+
<artifactId>spring-boot-webclient</artifactId>
22+
</dependency>
23+
1924
<dependency>
2025
<groupId>org.springframework.boot</groupId>
2126
<artifactId>spring-boot-starter-aspectj</artifactId>

spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-seata/src/main/java/com/alibaba/cloud/seata/webclient/SeataWebClientAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package com.alibaba.cloud.seata.webclient;
1818

1919
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
20-
import org.springframework.cloud.client.loadbalancer.reactive.WebClientCustomizer;
20+
import org.springframework.boot.webclient.WebClientCustomizer;
2121
import org.springframework.context.annotation.Bean;
2222
import org.springframework.context.annotation.Configuration;
2323
import org.springframework.web.reactive.function.client.WebClient;

spring-cloud-alibaba-starters/spring-cloud-starter-alibaba-seata/src/main/java/com/alibaba/cloud/seata/webclient/SeataWebClientBuilderCustomizer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616

1717
package com.alibaba.cloud.seata.webclient;
1818

19-
20-
import org.springframework.cloud.client.loadbalancer.reactive.WebClientCustomizer;
19+
import org.springframework.boot.webclient.WebClientCustomizer;
2120
import org.springframework.web.reactive.function.client.WebClient;
2221

2322
/**

spring-cloud-alibaba-starters/spring-cloud-starter-stream-rocketmq/src/main/java/com/alibaba/cloud/stream/binder/rocketmq/integration/inbound/RocketMQInboundChannelAdapter.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@
3434
import org.slf4j.LoggerFactory;
3535

3636
import org.springframework.cloud.stream.binder.ExtendedConsumerProperties;
37+
import org.springframework.core.retry.RetryException;
3738
import org.springframework.core.retry.RetryListener;
39+
import org.springframework.core.retry.RetryPolicy;
3840
import org.springframework.core.retry.RetryTemplate;
41+
import org.springframework.core.retry.Retryable;
3942
import org.springframework.integration.context.OrderlyShutdownCapable;
4043
import org.springframework.integration.core.RecoveryCallback;
4144
import org.springframework.integration.endpoint.MessageProducerSupport;
@@ -142,10 +145,12 @@ private <R> R consumeMessage(List<MessageExt> messageExtList,
142145
Message<?> message = RocketMQMessageConverterSupport
143146
.convertMessage2Spring(messageExt);
144147
if (this.retryTemplate != null) {
145-
// this.retryTemplate.execute(context -> {
146-
// this.sendMessage(message);
147-
// return message;
148-
// }, this.recoveryCallback);
148+
this.retryTemplate.setRetryListener(new RetryListener() {
149+
@Override
150+
public void onRetryPolicyExhaustion(RetryPolicy retryPolicy, Retryable<?> retryable, RetryException exception) {
151+
recoveryCallback.recover(null, exception);
152+
}
153+
});
149154
}
150155
else {
151156
this.sendMessage(message);

spring-cloud-alibaba-starters/spring-cloud-starter-stream-rocketmq/src/test/java/com/alibaba/cloud/stream/binder/rocketmq/RocketMQMessageChannelBinderTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import com.alibaba.cloud.stream.binder.rocketmq.properties.RocketMQConsumerProperties;
2424
import jakarta.annotation.Resource;
2525
import org.assertj.core.api.Assertions;
26-
import org.junit.jupiter.api.Disabled;
2726
import org.junit.jupiter.api.Test;
2827

2928
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -35,7 +34,6 @@
3534

3635
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.NONE;
3736

38-
@Disabled
3937
@SpringBootTest(classes = RocketMQMessageChannelBinderTest.TestConfig.class,
4038
webEnvironment = NONE,
4139
properties = {

0 commit comments

Comments
 (0)