In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Preface
Dubbo is an open source distributed service governance framework widely used by many domestic Internet companies, and it is a very comprehensive SOA basic framework. Dangdang added some functions on the basis of Dubbo and named it Dubbox (Dubbo eXtensions).
Why do I need Dubbo?
All the business processes in the past are in one system.
Then, the large system is divided into N business systems according to the business domain.
The interaction between various business systems is inevitable, so what should be adopted? The HTTP way? WebService? ...
We will face a lot of URL management, call chains between services, dependencies, service load balancing, monitoring, and so on.
What is Dubbo?
Dubbo is essentially a distributed service invocation, a high-performance and transparent RPC invocation scheme + SOA service governance scheme.
The architecture of Dubbo:
First, Dubbo has the concept of a registry Registry. The service provider Provider registers the service with Registry, and the consumer Consumer needs to discover and monitor changes in the service from the Registry.
Second, Provider needs to run in a Container container, and Dubbo provides Monitor to monitor the number of calls to the service and the call time.
Third, the commonly used Registry is Zookeeper,Redis, etc. Bloggers will use Zookeeper as the registration center. (please refer to "distributed sharp weapon Zookeeper (1)")
OK, said some theories, let's get started quickly!
QuickStart
Here I will show you an order service that invokes the Demo of a commodity service.
Goods and services: ProductService
Let's first take a look at the engineering structure of goods and services:
The ProductService project is divided into two Module: one is product-api and the other is product-service. You know, the so-called publishing service is to expose the interface to the public, and both producers and consumers need to reference the interface, so here the interface will be provided in product-api.
Rely on product-api and implement the interface in the product-service module:
Note that Product needs to implement the serialized Serializable interface.
As you can see from XML, we need to rely on dubbo, Zookeeper, and Curator in the product-service module. (I don't post XML here.)
Every service has a Name, but you can also specify an Owner.
The registry uses Zookeeper and the client uses the Curator framework.
Dubbo actually supports many protocols. The Dubbo protocol is specified above, and the external service port is 20880.
We need to publish the service, which is to register with Zookeeper and tell us what the interface is and what the service implementation corresponding to that interface is.
Start merchandise service:
What exactly does this startup mode do? Where did you read the configuration file? What about the start-up?
Let's take a look at the source code a little bit:
See how SpringContainer starts:
OK, here, the goods and services are ready!
Order Service: OrderService
Let's start with dependence:
Note that the order service depends on product-api.
Look at the dubbo configuration:
Consumer launch:
The result of consumer operation:
Look at Zookeeper:
It is very clear in Zookeeper that the interface will be created in the form of a directory node, and below the providers is the interface protocol, sub-machine, sub-protocol, so that load balancing can be achieved!
Dubbo-admin control console
Like rocketmq, dubbo is also provided to dubbo-admin.war, which can be directly deployed under Tomcat, and the registry address can be specified by modifying dubbo.properties.
Summary
Transparent remote calls, just like calling local methods, require simple configuration without any API intrusion!
We can add and decrease machines smoothly, and consumers can find service providers dynamically, so that our services avoid single-point problems, strong fault-tolerant mechanisms and soft load capabilities (you know that the hardware loader F5 is very expensive).
Dubbo and Spring integrate tightly and transparently to access applications!
Some thoughts
It is impossible for this blog to explain all the features and configurations of Dubbo, so here are some questions to think about and learn with you:
1. A service depends on B service. If B service is not started or disabled, can A service be started? Will Dubbo do service dependency invocation checks for us?
two。 Can we bypass the registry and call it directly?
3. Consider such a situation, if A calls B and the network jitter occurs and the call is abnormal, will dubbo retry the call for us at this time? If dubbo has a retry mechanism, does it mean that there are repeated calls? If our service is an operation on the database, will this retry mechanism cause an impact or a problem? What should we do with it? I seem to think of something about RocketMQ. Haha)
What load balancing mechanisms does 4.dubbo provide? Can it be specific to each method?
5. The invocation of the service, to the server end, must be called through the thread pool, so can we customize the thread pool according to different scenarios?
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.