All Projects → wu191287278 → spring-boot-starter-dubbo

wu191287278 / spring-boot-starter-dubbo

Licence: other
spring-boot-start-dubbo

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to spring-boot-starter-dubbo

Spring Samples For All
spring、spring-boot、spring-cloud 常用整合用例
Stars: ✭ 401 (+1442.31%)
Mutual labels:  zuul, dubbo
Spring Cloud Learning
☁️适合刚接触微服务架构的初学者了解和学习微服务,主要集成了注册中心、服务网关、配置中心、熔断机制、应用监控。
Stars: ✭ 37 (+42.31%)
Mutual labels:  zuul, feign
Spring Cloud Security
Security concerns for distributed applications implemented in Spring
Stars: ✭ 488 (+1776.92%)
Mutual labels:  zuul, feign
Fw Spring Cloud
SpringCloud构建实战、从入门到高级,包含eureka、zuul、gateway、feign、ribbon、hystrix、mq、turbine、nacos、elk、consul、zookeeper、rocketmq、kafka、分布式事务(RocketMq、LCN、Seata)、分库分表(Sharding-JDBC)、分布式锁(Redis、Guava)、jwt、SkyWalking、Zipkin、bootadmin等使用案例
Stars: ✭ 276 (+961.54%)
Mutual labels:  zuul, feign
Spring Cloud
SpringCloud微服务架构,提供快速上手脚手架,快速构建高可用注册中心,高可用配置中心,加入Hystrix断路器,gateway服务官网,权限认证、服务降级、限流,加入应用监控
Stars: ✭ 130 (+400%)
Mutual labels:  zuul, feign
Java Spring Cloud
Distributed tracing for Spring Boot, Cloud and other Spring projects
Stars: ✭ 326 (+1153.85%)
Mutual labels:  zuul, feign
Cxf Spring Cloud Netflix Docker
Example project combining Spring Boot apps with Spring Cloud Netflix (Eureka, Zuul, Feign) & cxf-spring-boot-starter
Stars: ✭ 29 (+11.54%)
Mutual labels:  zuul, feign
Sample Spring Microservices New
Demo for Spring Boot 2 and Spring Cloud microservices with distributed configuration (Spring Cloud Config), service discovery (Eureka), API gateway (Spring Cloud Gateway, Zuul), Swagger2 API documentation, logs correlation using Spring Cloud Sleuth and many more
Stars: ✭ 559 (+2050%)
Mutual labels:  zuul, feign
Tesla
Tesla is a gateway service that provides dynamic routing,waf,support spring cloud,gRPC,DUBBO and more.
Stars: ✭ 109 (+319.23%)
Mutual labels:  zuul, dubbo
Bookstoreapp Distributed Application
Ecommerce project is being developed using Spring Boot Microservices and Spring Cloud (Backend) and React (Frontend). Splitting the Ecommerce functionality into various individual microservices so that they can be distributed, scale really well and make use of resources efficiently.
Stars: ✭ 63 (+142.31%)
Mutual labels:  zuul, feign
spring-boot-microservice-eureka-zuul-docker-gateway-kubernetes
Spring Boot rest microservices using Kubernetes, ConfigMap, Eureka, Zuul / Spring Boot Gateway, Docker. Monitoring with logstash, logback, elasticsearch, kibana.
Stars: ✭ 86 (+230.77%)
Mutual labels:  zuul, feign
Spring Cloud Study
SpringCloud源码实战微服务框架(202003更新到SpringCloud的Greenwich版本,即基于SpringBoot2.1.7版本,以及新增SpringCloud Alibaba从入门到精通教程),涉及内容:配置中心,注册中心,服务提供者,服务消费者,熔断器,配置服务,API Gateway,API网关限流ratelimit,服务链路追踪zipkin,hystrix监控,监控聚合中心turbine等
Stars: ✭ 215 (+726.92%)
Mutual labels:  zuul, feign
Advanced Java
😮 Core Interview Questions & Answers For Experienced Java(Backend) Developers | 互联网 Java 工程师进阶知识完全扫盲:涵盖高并发、分布式、高可用、微服务、海量数据处理等领域知识
Stars: ✭ 59,142 (+227369.23%)
Mutual labels:  feign, dubbo
Superboot
随着技术日新月异,新技术新平台不断出现,对现如今的开发人员来说选择快速高效的框架进行项目开发,既能提高产出,又能节约时间。本框架无需开发即可实现服务注册、服务发现、负载均衡、服务网关、配置中心、API管理、分布式事务、支撑平台、集成框架、数据传输加密等功能,是学习SpringCloud整体业务模式的完整示例,并且可以直接用于生产环境
Stars: ✭ 341 (+1211.54%)
Mutual labels:  zuul, feign
java-best-practice
Java学习例子,最佳实践
Stars: ✭ 19 (-26.92%)
Mutual labels:  feign, dubbo
Spring Boot Microservice Eureka Zuul Docker
Spring-Boot rest microservices using Eureka, Zuul, Docker. Monitoring with logstash, logback, elasticsearch, kibana
Stars: ✭ 45 (+73.08%)
Mutual labels:  zuul, feign
Spring Boot Cloud
基于 Spring Boot、Spring Cloud、Spring Oauth2 和 Spring Cloud Netflix 等框架构建的微服务项目
Stars: ✭ 2,044 (+7761.54%)
Mutual labels:  zuul, feign
Springcloudlearning
《史上最简单的Spring Cloud教程源码》
Stars: ✭ 16,218 (+62276.92%)
Mutual labels:  zuul, feign
learning
学习笔记
Stars: ✭ 17 (-34.62%)
Mutual labels:  dubbo
spring-projects
Some spring sample projects
Stars: ✭ 24 (-7.69%)
Mutual labels:  feign

spring-boot-start-dubbo

  • Dubbo是阿里开发的一套分布式通讯框架,Spring-boot是业界比较火的微服务框架,两者可以进行结合实现分布式微服务
  • 对于内部远程Rpc调用,可以借用Dubbo能力,达到服务治理的目的

增加feign protocol支持

该协议主要是为了支持老项目可以消费springcloud提供的接口,并可以利用dubbo的服务发现,构建出一个springboot rest集群, dubbo与springboot结合时,不需要dubbo再次导出rest服务。而是由springboot提供rest服务dubbo端只负责注册,构建服务目录。

如何发布Dubbo服务

在Spring Boot项目的pom.xml中添加以下依赖:

 <dependency>
        <groupId>com.github.wu191287278</groupId>
        <artifactId>spring-boot-starter-dubbo</artifactId>
        <version>1.5.4</version>
 </dependency>

example


//服务端,多协议发布服务
@RestController
@Service(version = "1.0.0", protocol = {"dubbo","feign"}, timeout = 10000) //该注解仅仅是描述接口使用,并不会造成多次实例化
@RequestMapping(value = "/user/")
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    public User selectByPrimaryKey(@PathVariable("id") Long id) {
        return userDao.selectByPrimaryKey(id);
    }

    public Object insert(@RequestBody User t) {
        return userDao.insert(t);
    }

    public Object updateByPrimaryKey(@RequestBody User t) {
        return userDao.updateByPrimaryKey(t);
    }

    public int deleteByPrimaryKey(@PathVariable("id") Long id) {
        return userDao.deleteByPrimaryKey(id);
    }
    
}

@SpringBootApplication
@EnableDubboAutoConfiguration
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}


//消费端
@FeignClient(path = "/user")
@DubboClient(protocol = "feign", value = @Reference(timeout = 10000, version = "1.0.0"))
public interface UserService {

    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    User selectByPrimaryKey(@PathVariable("id") Long id);

    @RequestMapping(value = "{id}", method = RequestMethod.DELETE)
    int deleteByPrimaryKey(@PathVariable("id") Long id);

    @RequestMapping(value = "/", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
    Object insert(@RequestBody User t);

    @RequestMapping(value = "/", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
    Object updateByPrimaryKey(@RequestBody User t);

}

//测试

@SpringBootTest(classes = ConsumerApplication.class)
@RunWith(SpringJUnit4ClassRunner.class)
public class UserServiceTest {

    @Autowired
    private UserService userService;

    @Test
    public void testSelectByPrimaryKey() {
        User user = userService.selectByPrimaryKey(1L);
        System.err.println(user);
    }

    @Test
    public void testInsert() {
        userService.insert(new User()
                .setUsername("test")
                .setPassword("123456")
                .setCreatedTime(new Date())
                .setAddress("北京市"));

    }

    @Test
    public void testUpdate(){
        userService.updateByPrimaryKey(new User()
                .setId(2L)
                .setUsername("test")
                .setPassword("123456")
                .setCreatedTime(new Date())
                .setAddress("北京市"));
    }

    @Test
    public void testDelete(){
        userService.deleteByPrimaryKey(1L);
    }
}

在application.properties添加Dubbo的版本信息和客户端超时信息,如下:

spring:
  application:
    name: dubbo-demo-consumer
  dubbo:
    application:
      name: ${spring.application.name}
    protocol:
      name: feign
    registry:
      protocol: zookeeper
      address: localhost:2181
    scan: com.example

*网关支持,支持聚合dubbo rest服务同时兼容springcloud rest代理

maven 依赖

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-zuul</artifactId>
</dependency>

启动类

@SpringBootApplication
@EnableDubboProxy
public class DubboApplication {

    public static void main(String[] args) {
        SpringApplication.run(DubboApplication.class, args);
    }
}

配置文件

spring:
  application:
    name: dubbo-application

  dubbo:
    application:
      name: ${spring.application.name}
    registry:
      protocol: hazelcast
      address: 224.5.6.7:1234

泛化代理Dubbo转换成rest


spring:
  application:
    name: dubbo-application

  dubbo:
    application:
      name: ${spring.application.name}
    registry:
      protocol: hazelcast
      address: 224.5.6.7:1234
    generic-prefix: /proxy

//rest请求示例 localhost:8100/proxy/
{
	"params":[1],
	"method":"com.example.service.UserService.selectByPrimaryKey",
	"version":"1.0.0"
}

//返回结果
{
  "jsonrpc": "2.0",
  "id": null,
  "result": "{\"id\":1,\"username\":\"wuyu\",\"createdTime\":1493775816000,\"address\":\"安徽省阜阳市\",\"class\":\"com.example.model.User\",\"password\":\"123456\"}"
}


演示样例

https://git.oschina.net/wuyu15255872976/dubbo-demo-parent.git

新增Hazelcast 注册中心

spring:
  application:
    name: dubbo-application

  dubbo:
    application:
      name: ${spring.application.name}
    registry:
      protocol: hazelcast
      address: 224.5.6.7:1234?managementCenter=http://localhost:8080/mancenter #managementCenter 是hazelcast监控地址,可以不填写

Hazelcast 监控中心

地址:https://hazelcast.org/download/

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].