美文网首页
dubbo源码8-请求发送响应流程

dubbo源码8-请求发送响应流程

作者: modou1618 | 来源:发表于2019-01-05 22:25 被阅读0次

一 接口配置

1.1 接口

public interface UserService{

    /**
     * 依据id查找用户信息
     *
     * @param id 用户id
     * @return 用户,没有则返回null
     */
    User findById(long id);
}

1.2 consumer端

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
            http://code.alibabatech.com/schema/dubbo
            http://code.alibabatech.com/schema/dubbo/dubbo.xsd">

    <dubbo:application name="${dubbo.app.name}" environment="${dubbo.env}"/>

    <dubbo:registry protocol="zookeeper" address="${dubbo.address}" timeout="${zk.connection.timeout}"/>

    <dubbo:consumer group="${dubbo.group}" check="false" timeout="${dubbo.timeout}"
                    retries="${dubbo.retries}"/>

    <dubbo:reference id="userService" interface="com.greatnew.data.service.UserService"/>
</beans>

1.3 provider端

1.3.1 配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
            http://code.alibabatech.com/schema/dubbo
            http://code.alibabatech.com/schema/dubbo/dubbo.xsd">

    <dubbo:application name="${dubbo.app.name}" environment="${dubbo.env}"/>

    <dubbo:registry protocol="zookeeper" address="${dubbo.address}" timeout="${zk.connection.timeout}"/>

    <dubbo:protocol name="dubbo" port="${dubbo.port}"/>

    <dubbo:provider group="${dubbo.group}" retries="${dubbo.retries}"/>

    <dubbo:service interface="com.greatnew.data.service.UserService" ref="userServiceImpl"/>
</beans>

1.3.2 接口实现

public class UserServiceImpl implements UserService {
    @Override
    public User findById(long id) throws RepositoryException {
        return repository.findById(id);
    }
}

二 调用流程

image.png

相关文章

  • dubbo源码8-请求发送响应流程

    一 接口配置 1.1 接口 1.2 consumer端 1.3 provider端 1.3.1 配置 1.3.2 ...

  • 爬虫的概念

    爬虫是模拟浏览器发送请求,获取响应 爬虫的流程 url--->发送请求,获取响应--->提取数据---》保存数据 ...

  • dubbo剖析:五 网络通信之 -- 请求发送与接收

    注:文章中使用的dubbo源码版本为2.5.4 零、文章目录 Consumer发送请求 Provider接收请求并...

  • HTTP协议

    一、HTTP协议 二、请求流程 搜集数据 生成http请求报文 发送请求报文 接收响应报文 解析响应报文 展现结果

  • 2018-08-28

    爬虫的基本流程 一、发送HTTP请求(Request)通过Python库向目标站点发送HTTP请求,等待服务器响应...

  • 06-dubbo客户端接收请求过程

    前一篇文章分析了客户端发送请求的过程05-dubbo客户端调用流程分析现在再来分析客户端接收响应的过程。下面是接受...

  • Struts2入门01--基本知识

    1, Filter的工作流程 客户端发送请求,Filter可以拦截到请求的信息:servletPath,等,在响应...

  • 腾讯云基础知识防护(公私钥/防火墙)及部署

    请求和响应流程: 客户端发送请求给服务器,会经过防火墙过滤(比如80端口),如果可以通过,则把请求发送给监听80端...

  • Requests

    Requests库 目录一、Requests基础二、发送请求与接收响应(基本GET请求)三、发送请求与接收响应(基...

  • 从输入URL到页面展示的详细过程

    大致流程 输入网址 DNS解析 建立tcp连接 客户端发送HTTP请求 服务器处理请求 服务器响应请求 浏览器显示...

网友评论

      本文标题:dubbo源码8-请求发送响应流程

      本文链接:https://www.haomeiwen.com/subject/phxjrqtx.html