- What is Dubbo?
- Under the Crystal Framework, how do I develop a Dubbo RPC-based service?
- Under the Crystal Framework, how do I invoke the Dubbo RPC service?
- Related articles
What is Dubbo?
dubbo[] is a distributed service framework dedicated to providing high-performance and transparent RPC remote service invocation scenarios, as well as SOA service governance scenarios.
The core part contains:
- Remote communication: provides an abstract encapsulation of various NIO frameworks based on long connections, including multiple threading models, serialization, and "request-response" mode of information exchange.
- cluster fault tolerance: provides transparent remote procedure calls based on interface methods, including multi-protocol support, as well as soft load balancing, failure tolerance, address routing, dynamic configuration and other cluster support.
- Autodiscover: based on the Registry directory service, the service consumer can dynamically find the service provider, making the address transparent, allowing the service provider to increase or decrease the machine smoothly.
What can Dubbo do?
- A transparent remote method call, just like calling a local method, calls a remote method, simply configured without any API intrusion.
- Soft load balancing and fault-tolerant mechanism can replace hardware load balancer such as F5 in intranet, reduce cost and reduce single point.
- Service autoenrollment and discovery eliminates the need to write dead service provider addresses, the registry queries the IP address of the service provider based on the interface name, and is able to smoothly add or remove service providers.
For more information about Dubbo, please see: http://alibaba.github.io/dubbo-doc-static/Home-zh.htm
Under the Crystal Framework, how do I develop a Dubbo RPC-based service?
First step: Define the interface
- Create an interface jar project, such as: TEST-DUBBO-SERVICE-API;
There is no difference between creating an interface class and an interface method, and the usual interface definition, such as:
Public Interface testservice { /** * @param a @return */ Public string Test (String a);
Step two: Implement and publish the service
- Create a service implementation project, such as: Test-dubbo-service-impl;
Introduction of Interface Project (TEST-DUBBO-SERVICE-API), Crystal Framework Dubbo Service Support Package (CRYSTAL-REMOTE-SERVER-DUBBO), such as:
<Dependency> <groupId>Com.gsoft.test</groupId> <Artifactid>Test-dubbo-service-api</Artifactid></Dependency><Dependency> <groupId>Com.gsoft.crystal</groupId> <Artifactid>Crystal-remote-server-dubbo</Artifactid></Dependency>
Implement the service interface, such as:
@Service public class testserviceimpl Testservice {@Value ( "${crystal.application.name}" private String name; /* * (non-javadoc) * * @see com.gsof T.test.dubbo.testservice#test (java.lang.String) */ @Override public string Test (string a) { return "Hello," + A + "!" + "I ' m" + name + "" + system.getenv ("LO Gonserver ") +". "
Add the annotation @service on the implementation class, where the service is the declaration note Com.alibaba.dubbo.config.annotation.Service for the Dubbo service, where the services based on the Dubbo release have been developed and published.
Icon== = zookeeper://127.0.0.1:2181= 20880
Under the Crystal Framework, how do I invoke the Dubbo RPC service?
The first step: the project references the Dubbo Service interface package and the Crystal Framework Dubbo Client Support Package (CRYSTAL-REMOTE-CLIENT-DUBBO), as
<Dependency> <groupId>Com.gsoft.test</groupId> <Artifactid>Test-dubbo-service-api</Artifactid></Dependency><Dependency> <groupId>Com.gsoft.crystal</groupId> <Artifactid>Crystal-remote-client-dubbo</Artifactid></Dependency>
Step two: In the class that needs to use the Dubbo RPC service, add a reference to the service, and add @reference annotations: (here Reference the declaration annotations for the Dubbo service Com.alibaba.dubbo.config.annotation.Reference
Public class Testcostumer { @Reference private testservice s; Private int i = 0; @Value ("${crystal.application.name}") private String name; Public void Hello () { + "" + system.getenv ("logonserver") + "-" + + +i));} }
= == zookeeper://127.0.0.1:2181
How do I develop a distributed service based on Dubbo RPC?