dubbo source debugger

2.6.5 1. tag to a structure can be seen from the lower duboo github clone source and checkout:

 

 

Wherein the all-dubbo pom follows:

 

 

Other projects here will dubbo of hitting a bag in the package when noticed all here depend on other modules are optional, while others rely only on dubbo sub-modules will not be dependent on passing, which also means the child dependent module will not transfer, pay no attention to this, then, when debugging is easy to wonder why the corresponding depend not passed down.

3.mvn clean install -Dmaven.test.skip = true build com.alibaba get under local repository *:

 

4. Create a new project depends dubbo, lower resource and dubbo configured log4j configuration file:

<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
       xmlns="http://www.springframework.org/schema/beans"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
       http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">

    <!-- provider's application name, used for tracing dependency relationship -->
    <dubbo:application name="echo-provider"/>
    <!-- use multicast registry center to export service -->
    <dubbo:registry address="zookeeper://127.0.0.1:2181"/>
    <!-- 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="echoService" class="provider.EchoServiceImpl"/>
    <!-- declare the service interface to be exported -->
    <dubbo:service interface="facade.EchoService" ref="echoService"/>
</beans>

5.用spring的方式写一个provider:

import facade.EchoService;
import com.alibaba.dubbo.rpc.RpcContext;
import java.text.SimpleDateFormat;
import java.util.Date;

public class EchoServiceImpl implements EchoService {
    public String echo(String message) {
    String now=new SimpleDateFormat("HH:mm:ss").format(new Date());
    System.out.println("["+now+"] Hello"+message+", request from consumer"+RpcContext.getContext().getRemoteAddressString());
    return message;
    }
}

 6.启动zk集群。

7.start Spring容器,可以看到/dubbo/facade.EchoService/providers下的节点(/root/service/[provider,consumer,routers,confugurators]):(临时节点)

 

Guess you like

Origin www.cnblogs.com/lccsblog/p/11520871.html