Dubbo is easy to understand

Simple understanding of Dubbo

1. Zookeeper is used for interface management, so zookeeper
is required. 2. It is an application framework that implements remote program calls.


The architecture of Dubbo is shown in the figure:



Node role description:
Provider: The service provider that exposes the service.
Consumer: The service consumer that invokes the remote service.
Registry: A registry for service registration and discovery.
Monitor: The monitoring center that counts the invocation times and invocation time of the service.
Container: The service runs the container.


Description of the calling relationship:
0. The service container is responsible for starting, loading, and running the service provider.
1. When the service provider starts, it registers the service it provides with the registry.
2. When the service consumer starts, it subscribes to the registration center for the services it needs.
3. The registry returns the service provider address list to the consumer. If there is a change, the registry will push the change data to the consumer based on the persistent connection.
4. The service consumer, from the provider address list, selects a provider to call based on the soft load balancing algorithm, and if the call fails, select another provider to call.
5. Service consumers and providers accumulate the number of calls and call time in the memory, and regularly send statistical data to the monitoring center every minute.


Dubbo provides many protocols, Dubbo protocol, RMI protocol, Hessian protocol


configuration:
Provider:
<dubbo:application name="dubbo_provider"></dubbo:application>
//provider application name information, this is equivalent to a name, our dubbo management page is more clear which application is exposed


<dubbo:protocol name="dubbo" port="20880" />
//protocol definition,
//name protocol name,
//port listen port number
//

<dubbo:service interface="com.mor.server.dubbo.service.DemoServer"
        ref="demoService" />
<bean id="demoService" class="com.mor.server.dubbo.service.DemoServerImpl" />
//Define the service,
//interface is the interface of the service class,
//ref is the ID of the bean whose ref refers to the corresponding implementation class
//registry registers with the specified registry and is used in multiple registries. The value is the id attribute of <dubbo:registry>. Multiple registry IDs are separated by commas. If you do not want to register the service to any registry, you can set the value set to N/A
//register The default is true, whether the service of this protocol is registered to the registry.

<dubbo:registry  protocol="zookeeper"  address="192.9.145.19:2181,192.9.145.19:2182,192.9.145.19:2183"  />
//registry definition,
//protocol protocol type,
//address registry IP and port,
//register whether to register services with this registry, if set to false, it will only subscribe, not register.
//Check whether an error is reported when the registration center does not exist.
//subscribe whether to subscribe services to this registry, if set to false, it will only register, not subscribe.
//timeout registry request timeout time (milliseconds).

<dubbo:provider timeout="5000" />
// provider configuration,
//timeout, call timeout time
//registry, the value is the id attribute of <dubbo:registry>, indicating which registry to use
//protocol, the value is the id attribute of <dubbo:protocol>, indicating which protocol to use


Consumer:
<dubbo:application name="dubbo_provider"></dubbo:application>
//Consumer application name, used to calculate dependencies, not matching conditions, not the same as the provider

<dubbo:registry  protocol="zookeeper"  address="192.9.145.19:2181,192.9.145.19:2182,192.9.145.19:2183" />
//Registry center definition, protocol protocol type, address registry IP and port

<dubbo:reference id="demoService" interface="com.mor.server.dubbo.service.DemoServer" />
//The class to be referenced by the consumer, the id is the name, and the interface is the interface of the service class

<dubbo:consumer timeout="5000" />
//Consumer configuration,
//timeout, call timeout time




Reference text (Dubbo and Zookeeper, SpringMVC integration and use): https://my.oschina.net/farces/blog/639428
Reference text (detailed configuration file): http://www.cnblogs.com/linjiqin/p/ 5859153.html
Reference text (example): http://blog.csdn.net/morning99/article/details/40426781
Reference text (application description): http://dubbo.io/
Reference text (Dubbo token verification): http://blog.csdn.net/u010317829/article/details/52152709
Refer to the original text (springboot and dubbo integration): http://www.th7.cn/Program/java/201609/959357.shtml

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326920373&siteId=291194637