服务mock疑问
- Dominant language
- Go
- Stars
- 4.1k
- Forks
- 2.2k
- Avg merge
- 10d 12h
- Merged PRs (30d)
- 4
Description
- [x] I have searched the [issues](https://github.com/apache/dubbo-admin/issues) of this repository and believe that this is not a duplicate.
- [x] I have checked the [REAMDE](https://github.com/apache/dubbo-admin/blob/develop/README.md) of this repository and believe that this is not a duplicate.
### Environment
* Dubbo Admin version: 0.6.0
* Registry center detail (type and version): nacos 2.3.1
* Operating System version: centos 7
* Java version: 1.8
nacos、dubbo-admin docker启动,并且新建一个network,即启动时加了`--host nacos-br`
### Steps to reproduce this issue
1. code
```java
package com.xinji.boot.example; // 以下代码都在这个package
@SpringBootApplication
@EnableDubbo
public class DubboAdminMockExampleApplication {
public static void main(String[] args) {
SpringApplication.run(DubboAdminMockExampleApplication.class, args);
}
}
public interface MockService {
String sayHello(String name);
}
@RestController
@RequestMapping("mock")
public class MockConsumerController {
@DubboReference
private MockService mockService;
@GetMapping
public String mock() {
return mockService.sayHello("123");
}
}
```
2. 依赖
```
org.apache.dubbo.extensions
dubbo-mock-admin
3.2.0
org.apache.dubbo
dubbo-spring-boot-starter // 3.2.11
com.alibaba.boot
nacos-config-spring-boot-starter // 0.2.12
```
3. yml
```yaml
server:
port: 18080
dubbo:
application:
name: dubbo-admin-mock-example
protocol:
name: dubbo
port: -1
registry:
address: nacos://xxxxx:8848
```
5. dubbo-admin 服务mock添加: com.xinji.boot.example.MockService sayHello mock
6. idea 添加 jvm参数 `-Denable.dubbo.admin.mock=true`
Pls. provide [GitHub address] to reproduce this issue.
### Expected Result
What do you expected from the above steps?
### Actual Result
What actually happens?
If there is an exception, please attach the exception trace:
```
java.lang.IllegalStateException: Failed to check the status of the service com.xinji.boot.example.MockService. No provider available for the service com.xinji.boot.example.MockService from the url consumer://192.168.1.147/com.xinji.boot.example.MockService?application=dubbo-admin-mock-example&background=false&dubbo=2.0.2&executor-management-mode=isolation&file-cache=true&interface=com.xinji.boot.example.MockService&methods=sayHello&pid=308400®ister.ip=192.168.1.147&release=3.2.11&side=consumer&sticky=false×tamp=1715068057062&unloadClusterRelated=false to the consumer 192.168.1.147 use dubbo version 3.2.11
at org.apache.dubbo.config.ReferenceConfig.checkInvokerAvailable(ReferenceConfig.java:740) [dubbo-3.2.11.jar:3.2.11]
at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:379) [dubbo-3.2.11.jar:3.2.11]
at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:238) [dubbo-3.2.11.jar:3.2.11]
at org.apache.dubbo.config.ReferenceConfigBase.get(ReferenceConfigBase.java:395) [dubbo-3.2.11.jar:3.2.11]
at org.apache.dubbo.config.utils.SimpleReferenceCache.destroyReference(SimpleReferenceCache.java:294) [dubbo-3.2.11.jar:3.2.11]
at org.apache.dubbo.config.utils.SimpleReferenceCache.lambda$destroyAll$4(SimpleReferenceCache.java:285) [dubbo-3.2.11.jar:3.2.11]
at java.util.concurrent.ConcurrentHashMap.forEach(ConcurrentHashMap.java:1597) ~[na:1.8.0_362]
at org.apache.dubbo.config.utils.SimpleReferenceCache.destroyAll(SimpleReferenceCache.java:283) [dubbo-3.2.11.jar:3.2.11]
at org.apache.dubbo.config.deploy.DefaultModuleDeployer.unreferServices(DefaultModuleDeployer.java:569) ~[dubbo-3.2.11.jar:3.2.11]
at org.apache.dubbo.config.deploy.DefaultModuleDeployer.postDestroy(DefaultModuleDeployer.java:296) ~[dubbo-3.2.11.jar:3.2.11]
at org.apache.dubbo.rpc.model.ModuleModel.onDestroy(ModuleModel.java:111) ~[dubbo-3.2.11.jar:3.2.11]
at org.apache.dubbo.rpc.model.ScopeModel.destroy(ScopeModel.java:122) ~[dubbo-3.2.11.jar:3.2.11]
at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onContextClosedEvent(DubboDeployApplicationListener.java:189) ~[dubbo-3.2.11.jar:3.2.11]
at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:145) ~[dubbo-3.2.11.jar:3.2.11]
at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:52) ~[dubbo-3.2.11.jar:3.2.11]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[spring-context-5.3.15.jar:5.3.15]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[spring-context-5.3.15.jar:5.3.15]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[spring-context-5.3.15.jar:5.3.15]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421) ~[spring-context-5.3.15.jar:5.3.15]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378) ~[spring-context-5.3.15.jar:5.3.15]
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1058) ~[spring-context-5.3.15.jar:5.3.15]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.doClose(ServletWebServerApplicationContext.java:172) ~[spring-boot-2.6.3.jar:2.6.3]
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1021) ~[spring-context-5.3.15.jar:5.3.15]
at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:788) ~[spring-boot-2.6.3.jar:2.6.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) ~[spring-boot-2.6.3.jar:2.6.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) ~[spring-boot-2.6.3.jar:2.6.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) ~[spring-boot-2.6.3.jar:2.6.3]
at com.xinji.boot.example.DubboAdminMockExampleApplication.main(DubboAdminMockExampleApplication.java:12) ~[classes/:na]
```
然后我加了个yml如下配置禁止检查:
```
dubbo:
consumer:
check: false
```
然后 GET http://localhost:18080/mock 都是返回500。
Contributor guide
Research direction
Start with the provided DubboAdminMockExampleApplication entry point, MockService and MockConsumerController, then review the shown YAML, dependency versions, Docker network setup, and enable.dubbo.admin.mock JVM flag. Reproduce the startup failure and GET /mock response while checking the stack trace for service discovery and mock invocation behavior. Done means the example starts and GET /mock returns the configured mock result without the provider-availability failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, java, spring-boot
- Domain
- api, backend, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100