抱歉,您的浏览器无法访问本站
本页面需要浏览器支持(启用)JavaScript
了解详情 >

nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial Spring Cloud Cluster 1.0.1.RELEASE参考 Spring Cloud Cluster提供了分布式系统中集群的特性,例如选主,集群持久化信息储存,全局锁和一次性tok...

Spring Cloud Gateway

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package com.example.demo;

import java.util.ArrayList;
import java.util.List;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.gateway.event.RefreshRoutesEvent;
import org.springframework.cloud.gateway.route.RouteDefinition;
import org.springframework.cloud.gateway.route.RouteDefinitionRepository;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

// 动态路由
// https://zhuanlan.zhihu.com/p/125018436
@RestController
@SpringBootApplication
public class DemoApplication implements RouteDefinitionRepository, ApplicationEventPublisherAware {

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

// event publisher
ApplicationEventPublisher applicationEventPublisher;

@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.applicationEventPublisher = applicationEventPublisher;
}


// router
List<RouteDefinition> memery = new ArrayList<>();

private void refreshRoute() {
applicationEventPublisher.publishEvent(new RefreshRoutesEvent(this));
}

@PutMapping
Mono<Void> putRoute(@RequestBody Mono<RouteDefinition> o) {
return o.flatMap(routeDefinition -> {
memery.add(routeDefinition);
refreshRoute();
return Mono.empty();
});
}

@PostMapping
Mono<Void> postRoute(@RequestBody Mono<RouteDefinition> o) {
return o.flatMap(routeDefinition -> {
for (int i = 0; i < memery.size(); i++) {
if (memery.get(i).getId().equals(routeDefinition.getId())) {
memery.set(i, routeDefinition);
}
}
refreshRoute();
return Mono.empty();
});
}

@DeleteMapping
Mono<Void> deleteRoute(@RequestBody Mono<String> o) {
return o.flatMap(id -> {
memery.removeIf(routeDefinition -> routeDefinition.getId().equals(id));
refreshRoute();
return Mono.empty();
});
}

@GetMapping
Mono<List<RouteDefinition>> getRoute(){
return Mono.just(memery);
}

@Override
public Flux<RouteDefinition> getRouteDefinitions() {
return Flux.fromIterable(memery);
}

@Override
public Mono<Void> save(Mono<RouteDefinition> route) {
return Mono.empty();
}

@Override
public Mono<Void> delete(Mono<String> routeId) {
return Mono.empty();
}
}

nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial Feign1234567891011121314151617181920212223242526272829303132333435363738394041424344import com.fas...

nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial EurekaNetfilx在设计Eureka的时候遵守的就是AP原则,Eureka是一个Netfix的子模块, 也是核心模块之一,Eureka是一个基于REST的服务,用于实现云端中间层服务发现和故...

nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial 架构约定 > 配置 > 编码先写pom,xml,yml,sql,然后写dao,写Mapper,Service,Controller 起步用上面的方法建立一个Restful风格的服务端生产...

入门资料

中文文档
官方文档
中文文档
社区
嘿嘿

微服务于微服务架构

微服务强调服务的大小,他关注某一个点,一个模块只做一种事情
微服务架构通常而言,他提倡将单一的程序划分为一组小的服务,每个服务运行在独立的进程中,采用轻量级的通信机制 doubbo是rpc,springcloud是restful

集群/分布式

集群是多台计算机为了完成同一个工作,组合在一起达到更高的效率的系统

分布式是为了完成一个工作,将工作拆分为多个服务,分别运行在不同机器上的系统