Skip to content

Commit fa839d5

Browse files
committed
to #77,support throw mock exception
1 parent 9b3ce5c commit fa839d5

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

mse-simple-demo/C/src/main/java/com/alibabacloud/mse/demo/CApplication.java

+7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import javax.servlet.http.HttpServletRequest;
2020

2121
import org.springframework.beans.factory.annotation.Autowired;
22+
import org.springframework.beans.factory.annotation.Value;
2223
import org.springframework.boot.SpringApplication;
2324
import org.springframework.boot.autoconfigure.SpringBootApplication;
2425
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
@@ -55,8 +56,14 @@ class AController {
5556
@Autowired
5657
InetUtils inetUtils;
5758

59+
@Value("${throwException:false}")
60+
boolean throwException;
61+
5862
@GetMapping("/c")
5963
public String c(HttpServletRequest request) {
64+
if (throwException) {
65+
throw new RuntimeException();
66+
}
6067
return "C" + SERVICE_TAG + "[" + inetUtils.findFirstNonLoopbackAddress().getHostAddress() + "]";
6168
}
6269
}

mse-simple-demo/C/src/main/java/com/alibabacloud/mse/demo/service/HelloServiceCImpl.java

+8
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,17 @@ public class HelloServiceCImpl implements HelloServiceC {
2828
@Value("${rocketmq.consumer.topic}")
2929
private String topic;
3030

31+
32+
@Value("${throwException:false}")
33+
boolean throwException;
34+
3135
@Override
3236
public String hello(String name) {
3337

38+
if (throwException) {
39+
throw new RuntimeException();
40+
}
41+
3442
String value = "C" + SERVICE_TAG + "[" + inetUtils.findFirstNonLoopbackAddress().getHostAddress() + "]";
3543
String invokerTag="";
3644
String userData = RpcContext.getContext().getAttachment("__microservice_tag__");

0 commit comments

Comments
 (0)