Dubbo instance + source code

1. Project directory structure


Where edu_service_user is the provider of the service, and edu-web_boss is the consumer of the service


QQ picture 20180506151428.png


Two xml core configuration

①, service provider

<!-- provider application information, used to calculate dependencies -->
	<dubbo:application name="gw-service-user" />

	<!-- Use the zookeeper registry to expose the service address -->
	<dubbo:registry protocol="zookeeper" address="192.168.201.1:2181" />

	<!-- Expose services on port 20880 using the dubbo protocol -->
	<dubbo:protocol name="dubbo" port="20880" />
		
	<!-- User service interface -->
	<dubbo:service interface="wusc.edu.facade.user.service.PmsUserFacade" ref="pmsUserFacade" />

(Explanation: address is the current ip interface of my machine: the interface that provides services)


---------------------------------------------------------------------------------------------------------------------------------------------

②, the service consumer

<!-- Consumer application name, used to calculate dependencies, not matching conditions, not the same as the provider -->
	<dubbo:application name="edu-web-boss" />

	<!-- Use the zookeeper registry to expose the service address -->
	<!-- Registration Center Address -->
	<dubbo:registry protocol="zookeeper" address="192.168.201.1:2181" />
	
	<!-- User service interface -->
	<dubbo:reference interface="wusc.edu.facade.user.service.PmsUserFacade" id="pmsUserFacade" check="false" />

This is similar to the configuration of the service provider

Three, start the effect

  • ①, start Zookeeper first (I am running on Windows here) 

           Installation process

  •  ② , install the dubbo console 

          Installation process

*(The installation package is at the end of the article)*

  •  ③, start Tomcat

  •  ④. Register the service to Zookeeper and run the code as follows

          QQ picture 20180506150237.png

  •  ⑤, run the project, run the console (127.0.0.1:8080/)

 The effect diagram is as follows

QQ picture 20180506150417.png

 The final picture of the project is as follows

QQ picture 20180506151930.png

 A simple code example is like this, the project source code

 

 

  


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325341113&siteId=291194637