`

Dubbo

RPC 
阅读更多

 

Overview

(+) (#)

Serving 1,000+ services with 1,000,000,000+ invocations everyday, Dubbo becomes the key part of Alibaba's SOA solution and has been deployed to the whole alibaba.com family:

So, What is Dubbo?

Dubbo [] is a distributed service framework enpowers applications with service import/export capability with high performance RPC.

It's composed of three kernel parts:

  • Remoting: a network communication framework provides sync-over-async and request-response messaging.
  • Clustering: a remote procedure call abstraction with load-balancing/failover/clustering capabilities.
  • Registry: a service directory framework for service registration and service event publish/subscription

Dubbo can:

  • Integrate different types of RPC solutions(RMI/Hessian...) with unified behavior by the abstraction layer of RPC
  • Support out-of-box, plug-able load balancing and fault tolerance strategies.
  • Achieve graceful service upgrade/downgrade with service registry.

Quick Start

(+) (#)

Dubbo also support usage WITHOUT spring, please refer to: API Reference

Service Provider

(#)

Define the service interface:

DemoService.java
package com.alibaba.dubbo.demo;
 
public interface DemoService {
 
    String sayHello(String name);
 
}

Provide the service implementation

DemoServiceImpl.java
package com.alibaba.dubbo.demo.provider;
 
import com.alibaba.dubbo.demo.DemoService;
 
public class DemoServiceImpl implements DemoService {
 
    public String sayHello(String name) {
        return "Hello " + name;
    }
 
}

Setup the spring configuration

provider.xml
<?xml version="1.0" encoding="UTF-8"?>
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        ">
 
    <!-- Application name -->
    <dubbo:application name="hello-world-app"  />
 
    <!-- registry address, used for service to register itself -->
    <dubbo:registry address="multicast://224.5.6.7:1234" />
 
    <!-- expose this service through dubbo protocol, through port 20880 -->
    <dubbo:protocol name="dubbo" port="20880" />
 
    <!-- which service interface do we expose? -->
    <dubbo:service interface="com.alibaba.dubbo.demo.DemoService" ref="demoService" />
 
    <!-- designate implementation -->
    <bean id="demoService" class="com.alibaba.dubbo.demo.provider.DemoServiceImpl" />
 
</beans>

Kick it off with following java code

Provider.java
import org.springframework.context.support.ClassPathXmlApplicationContext;
 
public class Provider {
 
    public static void main(String[] args) throws Exception {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"provider.xml"});
        context.start();
 
        System.out.println("Press any key to exit.");
        System.in.read();
    }
 
}

Congrats! The DemoService now is exported by dubbo and waiting for incoming requests at port 20880.

Service Consumer

(#)

Setup the spring XML

consumer.xml
<?xml version="1.0" encoding="UTF-8"?>
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        ">
 
    <!-- consumer application name -->
    <dubbo:application name="consumer-of-helloworld-app"  />
 
    <!-- registry address, used for consumer to discover services -->
    <dubbo:registry address="multicast://224.5.6.7:1234" />
 
    <!-- which service to consume? -->
    <dubbo:reference id="demoService" interface="com.alibaba.dubbo.demo.DemoService" />
 
</beans>

Client side java code.

Consumer.java
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.alibaba.dubbo.demo.DemoService;
 
public class Consumer {
 
    public static void main(String[] args) throws Exception {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"consumer.xml"});
        context.start();
 
        DemoService demoService = (DemoService)context.getBean("demoService"); // get service invocation proxy
        String hello = demoService.sayHello("world"); // do invoke!
 
        System.out.println( hello ); // cool, how are you~
    }
 
}

For more, please click here for a complete user guide.

分享到:
评论
1 楼 小黄牛 2016-11-23  
分享个分布式架构Dubbo项目实战参考内容:http://www.roncoo.com/course/view/f614343765bc4aac8597c6d8b38f06fd

相关推荐

    Dubbo 2.5.3 jar包

    Dubbo 2.5.3 全部jar包下载 [INFO] dubbo-parent ...................................... SUCCESS [1.042s] [INFO] Hessian Lite(Alibaba embed version) ............... SUCCESS [4.438s] [INFO] dubbo-common .....

    dubbo示例代码dubbo-sample

    【Dubbo 示例代码详解】 Dubbo 是阿里巴巴开源的一款高性能、轻量级的Java服务治理框架,它主要提供了RPC(远程过程调用)服务,并且包含了服务注册与发现、负载均衡、容错处理、监控等全面的服务治理功能。本示例...

    incubator-dubbo-dubbo-2.6.1

    【标题】"incubator-dubbo-dubbo-2.6.1" 是一个Apache Incubator项目Dubbo的特定版本,这里的2.6.1表示该版本是Dubbo的稳定分支之一。 【描述】提到的"incubator-dubbo-dubbo-2.6.1"表明这是Apache孵化器中的Dubbo...

    Dubbo入门_实战

    ### Dubbo入门实战详解 #### 一、Dubbo概述与应用场景 ##### 1.1 什么是Dubbo? Dubbo是一款由阿里巴巴开发的分布式服务框架,它致力于提供高性能和透明化的RPC远程服务调用方案。该框架是阿里巴巴SOA服务化治理...

    dubbo资源 dubbo-admin dubbo demo

    【标题】"dubbo资源 dubbo-admin dubbo demo" 提供的是关于Apache Dubbo的相关素材,主要包括了Dubbo-admin的管理和示例项目。Dubbo是一个高性能、轻量级的开源Java RPC框架,它提供了丰富的服务治理功能,是阿里...

    dubbo-demo-consumer、dubbo-demo-provider、dubbo-simple-monitor

    《Dubbo实战:消费者、提供者与简单监控》 Dubbo是阿里巴巴开源的一款高性能、轻量级的服务治理框架,广泛应用于分布式系统中的服务调用。本篇将详细讲解基于dubbo-demo-consumer、dubbo-demo-provider和dubbo-...

    dubbo-admin包

    【标题】"dubbo-admin包"是Dubbo框架的一个重要组成部分,主要用作服务治理的管理界面。这个压缩包包含了运行Dubbo管理控制台所需的所有文件,使得开发者和运维人员可以方便地监控、管理和配置Dubbo服务。 【描述】...

    dubbo源码分析系列

    《Dubbo源码分析系列》是一份深入探讨Java开源框架Dubbo核心原理和技术细节的资料。Dubbo,作为阿里巴巴的一款高性能、轻量级的服务治理框架,它为分布式系统提供了服务发现、调用、负载均衡、容错等关键功能。这份...

    dubbo admin jdk1.8

    【标题】"dubbo admin jdk1.8" 指的是使用Java开发工具包(JDK)1.8版本运行的Dubbo管理控制台。Dubbo是阿里巴巴开源的一个高性能、轻量级的服务治理框架,它提供了服务注册、服务发现、调用监控等功能。在JDK1.8...

    dubbo-admin-2.5.4及dubbo-monitor-2.5.3 安装及配置

    本人实际测试过,这两个包可用。...2.修改dubbo-monitor中的conf目录中的dubbo.properties dubbo.registry.address 与 dubbo-admin中的配置一样 3.到dubbo-monitor中的bin目录下运行 start.sh脚本 ok

    dubbo视频教程|基于Dubbo的分布式系统架构实战

    Dubbo是阿里巴巴开源的分布式服务化治理框架(微服务框架),久经阿里巴巴电商平台的大规模复杂业务的高并发考验,到目前为止Dubbo仍然是开源界中体系最完善的服务化治理框架,因此Dubbo被国内大量的的互联网公司和...

    dubbo捕获自定义异常_dubbo异常捕获_dubbo异常_自定义异常_捕捉异常_

    在分布式服务框架 Dubbo 中,异常处理是必不可少的一部分。Dubbo 提供了强大的异常处理机制,使得服务提供者能够向消费者传递自定义异常,从而帮助消费者更好地理解和处理服务调用中的错误情况。本文将深入探讨如何...

    尚硅谷最新dubbo视频

    本套视频从分布式系统的基本概念出发,由浅入深,讲解了RPC原理,Dubbo基本使用,Dubbo高可用场景以及Dubbo原理,涉及了分布式系统中服务注册、服务发现、负载均衡、灰度发布、集群容错、服务降级等核心概念的讲解及...

    dubbo2.5.6.zip

    《Dubbo 2.5.6与Java 1.8的兼容性问题解析》 Dubbo,作为阿里巴巴开源的一款高性能、轻量级的服务治理框架,广泛应用于分布式系统中。而Java,作为服务端开发的基石,其版本选择直接影响到框架的运行效果。本篇文章...

    dubbo xsd的支持

    在IT行业中,Dubbo是一个非常知名的Java开源框架,主要用于实现分布式服务治理。它由阿里巴巴开发并维护,旨在提供高性能、轻量级的服务间调用方案。"dubbo.xsd"文件是Dubbo框架中用于XML配置文件解析的重要组成部分...

    dubbo 对外提供和使用接口方法

    ### dubbo对外提供和使用接口方法 #### 一、Dubbo简介 Dubbo是一个高性能、轻量级的开源服务框架,旨在提供高性能和透明化的RPC远程服务调用方案,是微服务架构的重要组成部分之一。它提供了面向接口代理的高性能...

    Dubbo高级视频教程

    ### Dubbo高级视频教程知识点概览 #### 一、Dubbo概述与分布式系统基础 - **Dubbo简介**:Dubbo是一款高性能、轻量级的开源Java RPC框架,旨在为服务治理提供简单、全面的解决方案。 - **分布式系统概念**:分布式...

    dubbo入门例子程序

    【Dubbo入门例子程序】是针对初学者设计的一个简单示例,旨在帮助理解并快速上手Apache Dubbo这一高性能、轻量级的Java远程服务框架。这个例子通过一个"Hello, World!"的应用来演示Dubbo的基本用法,采用Maven作为...

    Dubbo监控系统配置

    ### Dubbo监控系统配置详解 #### 一、Dubbo监控系统概述 Dubbo是一款高性能、轻量级的开源服务框架,旨在提供高性能和透明化的RPC远程服务调用方案,以及SOA服务治理方案。Dubbo提供了包括服务自动注册与发现、...

    dubbo接口测试调试工具

    前段时间排查某问题的时候,想要快速知道某些dubbo接口(三无)的响应结果,但不想启动项目(因为这些项目不是你负责的,不会部署而且超级笨重),也不想新建一个dubbo客户端项目(占地方),也不想开telnet客户端...

Global site tag (gtag.js) - Google Analytics