Dubbo+zookeeper搭配分布式服务的过程详解

网友投稿 300 2022-08-06


Dubbo+zookeeper搭配分布式服务的过程详解

目录分布式架构: Dubbo 是什么Dubbo:思想:依赖:

分布式架构:

1.当垂直应用越来越多,应用之间交互不可避免,将核心业务抽取出来,作为独立的服务,逐渐形成稳定的服务中心,前端应用能更快速的响应多变的市场需求。 2.此时,用于提高业务复用及整合的 分布式服务框架(RPC) 是关键。

Dubbo 是什么

一款分布式服务框架高性能和透明化的RPC远程服务调用方案SOA服务治理方案

Dubbo:

作为分布式架构比较后的框架,同时也是比较容易入手的框架,适合作为分布式的入手框架,下面是简单的搭建过程

工具:idea+tomact+zookeeper (知识点:jsp,spring,springmvc,maven)

思想:

依赖:

org.springframework

spring-context

5.2.5.RELEASE

org.springframework

spring-webmvc

5.2.5.RELEASE

com.alibaba

dubbo

2.6.2

<!--zookeeper依赖-->

org.apache.curator

curator-framework

4.1.0

com.atchengdu

001-interface

1.0-SNAPSHOT

工程分布:

provider实现interface提供服务,constomer消费provider提供的服务

interface:

package com.atchengdu.serviceinterface;

imphttp://ort com.atchengdu.pojo.User;

public interface Userservice {

//获取user的信息

User getuserByid(Integer ie);

}

package com.atchengdu.pojo;

import java.io.Serializable;

public class User implements Serializable {

private Integer id ;

private String name;

public User(Integer id, String name) {

this.id = id;

this.name = name;

}

public User() {

public Integer getId() {

return id;

public void setId(Integer id) {

public String getName() {

return name;

public void setName(String name) {

@Override

public String toString() {

return "User{" +

"id=" + id +

", name='" + name + '\'' +

'}';

provider:

package com.atchengdu.Modulserviceimpl;

import com.atchengdu.pojo.User;

import com.atchengdu.serviceinterface.Userservice;

public class Userserviceimpl implements Userservice {

@Override

public User getuserByid(Integer ie) {

User user=new User(1,"张三");

return user;

}

}

xmlns:xsi="http://w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"

xsi:schemaLocation="http://springframework.org/schema/beans http://springframework.org/schema/beans/spring-beans.xsd

http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">

xmlns:xsi="http://w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"

xsi:schemaLocation="http://springframework.org/schema/beans http://springframework.org/schema/beans/spring-beans.xsd

http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">

constomer:

package com.atchengdu.webcontroller;

import com.atchengdu.pojo.User;

import com.atchengdu.serviceinterface.Userservice;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;

import org.springframework.ui.Model;

import org.springframework.web.bind.annotation.RequestMapping;

@Controller

public class Usercontroller {

@Autowired

private Userservice userservice;

@RequestMapping("/user")

public String user(Model model,Integer id ){

User user = userservice.getuserByid(id);

model.addAttribute("user",user);

return "user";

}

}

xmlns:xsi="http://w3.org/2001/XMLSchema-instance"

xmlns:context="http://springframework.org/schema/context"

xmlns:aop="http://springframework.org/schema/aop"

xmlns:mvc="http://springframework.org/schema/mvc"

xmlns:tx="http://springframework.org/schema/task"

xsi:schemaLocation="http://springframework.org/schema/beans http://springframework.org/schema/beans/spring-beans.xsd

http://springframework.org/schema/context http://springframework.org/schema/context/spring-context.xsd

http:// http://springframework.org/schema/task https://springframework.org/schema/task/spring-task.xsd

http://springframework.org/schema/aop https://springframework.org/schema/aop/spring-aop.xsd

http://springframework.org/schema/mvc https://springframework.org/schema/mvc/spring-mvc.xsd">

xmlns:xsi="http://w3.org/2001/XMLSchema-instance"

xmlns:context="http://springframework.org/schema/context"

xmlns:aop="http://springframework.org/schema/aop"

xmlns:mvc="http://springframework.org/schema/mvc"

xmlns:tx="http://springframework.org/schema/task"

xsi:schemaLocation="http://springframework.org/schema/beans http://springframework.org/schema/beans/spring-beans.xsd

http://springframework.org/schema/context http://springframework.org/schema/context/spring-context.xsd

http:// http://springframework.org/schema/task https://springframework.org/schema/task/spring-task.xsd

http://springframework.org/schema/aop https://springframework.org/schema/aop/spring-aop.xsd

http://springframework.org/schema/mvc https://springframework.org/schema/mvc/spring-mvc.xsd">

xmlns:xsi="http://w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"

xsi:schemaLocation="http://springframework.org/schema/beans http://springframework.org/schema/beans/spring-beans.xsd

http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">

xmlns:xsi="http://w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"

xsi:schemaLocation="http://springframework.org/schema/beans http://springframework.org/schema/beans/spring-beans.xsd

http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Dubbo+zookeeper 最简单的分布式搭建方案
下一篇:SpringBoot整合minio快速入门教程(代码示例)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~