A small starter case for Dubbox

Dubbox

A little story about Dubbox's life experience

Dubbox turned out to be Ali's own son, Dubbo, but later Ali gave birth to a young son HSF. As the saying goes, if you have a new love, you still need an old love. So Dubbo was kicked out of the house by Ali and lived on the streets
. People's Road, Dangdang felt that Dubbo was a talented person, so he adopted Dubbo, and in order to bid farewell to the past suffering days, Dubbo changed his name to Dubbox.

What is Dubbox used for?

Dubbox is committed to providing high-performance and transparent RPC remote service invocation solutions, as well as SOA service governance solutions. To put it simply, dubbox is a service framework. If there is no distributed demand, it is actually unnecessary. Only when it is distributed, there is a demand for a distributed service framework like dubbox, and it is essentially a service call. Dongdong, to put it bluntly, is a distributed framework for remote service calls.

Dubbox entry case

producer
@Service//这里的 Service是com.alibaba.dubbo.config.annotation.Service
public class UserServiceImpl implements UserService {
    @Override
    public String getName() {
        return "HelloWorld";
    }
}

xml placement

<dubbo:application name="dubboxdemo-service"/>  
<dubbo:registry address="zookeeper://192.168.24.125:2181"/> 
<dubbo:annotation package="cn.dubbodemo.service" />    
</beans>
consumer
@RestController
@RequestMapping(value="/user")
public class UserController {
    @Reference
    private UserService userService;//消费者需要导入生产者的接口
    @RequestMapping(value="/showName")
    public String showName() {
        return userService.getName();
    }
}

xml placement

<mvc:annotation-driven>
        <mvc:message-converters register-defaults="false">
            <bean class="org.springframework.http.converter.StringHttpMessageConverter">
                <constructor-arg value="UTF-8" />
            </bean>
        </mvc:message-converters>
    </mvc:annotation-driven>
    <!-- 引用 dubbo 服务 -->
    <dubbo:application name="dubboxdemo-web" />
    <dubbo:registry address="zookeeper://192.168.25.135:2181" />
    <dubbo:annotation package="cn.dubbodemo.controller" />
</beans>

operation result:
write picture description here

monitoring Center:
write picture description here
write picture description here

Not responsible for talking about the operation of Dubbox

write picture description here

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.
Since I like to watch Hong Kong-made gangster films in the 1980s and 1990s, I will explain the above picture with some plots in the gangster films. Of course, if what I said is not good, then you can just watch it, who will let me Did you click in? In the
above picture, you should add a 0 to the container. After all, the first step is to start it through the container, but when running the code, how can you not need to start it? So there is no 0 written, and generally For example, Dubbox's containers all use spring, so I'm too lazy to talk about containers.
①: In my opinion, the so-called producer is actually a gangster movie that specializes in improving advanced entertainment. When there are new service providers When Xiaohong appears, she must report her information to Liangkun, a senior entertainment manager .
: Brother Xia, who has always liked flowers and plants , wanted to relax after teaching a certain Nan, so he asked Liangkun if he had any New service worker,
③: After learning about Brother Xia 's needs, because Brother Xia doesn't like to go to the store, Liangkun sent the message of the new Xiaohong to Brother Xia .
④: Brother XiaAfter getting Xiaohong 's information from Liangkun , they made a direct phone call to Xiaohong. After some negotiation, the two reached an agreement to serve the person being served. ⑤: After the service is completed, or during the service process, Maybe Xiaohong's skills are not good, and Brother Chi is not satisfied. Or maybe Brother Chi is getting used to it and wants to eat Bawang*, just enjoy the service, but not give money. The two have a dispute, and everyone is not easy to adjust. At this time, the minister will pass With his eyes that see through everything, he calls out the monitor and restores what happened. Those who should pay the money should pay, and those who should be served should be served well. ... In my understanding, the above picture is probably like this. The solid line in the picture The part is equivalent to the series connection in electricity, and the dotted line part is equivalent to the parallel connection. In java, it is ajax.


⑥: Later, because Liang Kun was too showy and too trustworthy, he said that "the whole family should be ***, the whole family should be ***", and he could not do the management work well. At this time, a guy named Crow appeared in the rivers and lakes, Crow One When he came out, he used tough means to show his powerful abilities to all the bigwigs, so he was regarded as a senior service manager by default by all the bigwigs. And the crow 's name in the program arena is Zookeeper.

Zookeeper

zookeeper, registry. It is responsible for the registration and search of service addresses, which is equivalent to a directory service. Service providers and consumers only interact with the registration center at startup, and the registration center does not forward requests, so there is less pressure. Zookeeper is a sub-project of Apache Hadoop. It is a tree-type directory service that supports change push. It is suitable as a registry for Dubbox services. It has high industrial strength and can be used in production environments.

Guess you like

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