dubbo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] apel-apel commented on issue #1498: 服务端崩溃,报RpcException(Forbid consumer)时,mock无效
Date Thu, 22 Mar 2018 08:31:47 GMT
apel-apel commented on issue #1498: 服务端崩溃,报RpcException(Forbid consumer)时,mock无效
URL: https://github.com/apache/incubator-dubbo/issues/1498#issuecomment-375172819
   ### similar question
   I feel that the mock is not work,this is my spring xml config about dubbo below:
   <!-- provider's application name, used for tracing dependency relationship -->
       <dubbo:application name="demo-provider"/>
       <!-- use multicast registry center to export service -->
       <dubbo:registry address="multicast://"/>
       <!-- use dubbo protocol to export service on port 20880 -->
       <dubbo:protocol name="dubbo" port="20880"/>
       <!-- service implementation, as same as regular local bean -->
       <bean id="demoService" class="com.alibaba.dubbo.demo.provider.DemoServiceImpl"/>
       <!-- declare the service interface to be exported -->
       <!--<dubbo:service interface="com.alibaba.dubbo.demo.DemoService" mock="com.alibaba.dubbo.demo.DemoServiceMock"/>-->
       <dubbo:service interface="com.alibaba.dubbo.demo.DemoService" ref="demoService"
mock="com.alibaba.dubbo.demo.DemoServiceMock" />
   <!-- consumer's application name, used for tracing dependency relationship (not a matching
       don't set it same as provider -->
       <dubbo:application name="demo-consumer"/>
       <!-- use multicast registry center to discover service -->
       <dubbo:registry address="multicast://"/>
       <!-- generate proxy for the remote service, then demoService can be used in the
same way as the
       local regular interface -->
       <dubbo:reference id="demoService" check="false" interface="com.alibaba.dubbo.demo.DemoService"
   my provider obviously throw a RpcExcepton, and I expect the mock result return, but consumer
still throws the exception;
   my provider class:
   public class DemoServiceImpl implements DemoService {
       public String sayHello(String name) {
           System.out.println("[" + new SimpleDateFormat("HH:mm:ss").format(new Date()) +
"] Hello " + name + ", request from consumer: " + RpcContext.getContext().getRemoteAddress());
           if (true) {
               throw new RpcException("system error");
           return "Hello " + name + ", response form provider: " + RpcContext.getContext().getLocalAddress();
   my mock class:
   public class DemoServiceMock implements DemoService {
       public DemoServiceMock() {
       public String sayHello(String name) {
           return "I am mock";
   is there something wrong?

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:

With regards,
Apache Git Services

View raw message