reactive

Dubbo 3.0 !提升不止一点点!

蹲街弑〆低调 提交于 2019-12-04 08:27:13
Dubbo 自 2011 年 10 月 27 日开源后,已被许多非阿里系的公司使用,其中既有当当网、网易考拉等互联网公司,也不乏中国人寿、青岛海尔等大型传统企业。 自去年 12 月开始,Dubbo 3.0 便已正式进入开发阶段,并备受社区和广大 Dubbo 用户的关注。 本文将为您详细解读 Dubbo 3.0 预览版的新特性和新功能。 下面先解答一下两个有意思的与 Dubbo 相关的疑问: 1、为什么 Dubbo 一开源就是 2.0 版本?之前是否存在 1.0 版本? 笔者曾做过 Dubbo 协议的适配兼容,Dubbo 确实存在过 1.x 版本,而且从协议设计和模型设计上都与 2.0 的开源版本协议是完全不一样的。下图是关于 Dubbo 的发展路径: 2、阿里内部正在使用 Dubbo 开源版本吗? 是的,非常确定,当前开源版本的 Dubbo 在阿里巴巴被广泛使用,而阿里的电商核心部门是用的 HSF2.2 版本,这个版本是兼容了 Dubbo 使用方式和 Remoting 协议。当然,我们现在正在做 HSF2.2 的升级,直接依赖开源版本的 Dubbo 来做内核的统一。所以,Dubbo 是得到大规模线上系统验证的分布式服务框架,这一点毋容置疑。 Dubbo 3.0 预览版的要点 Dubbo 3.0 在设计和功能上的新增支持和改进,主要是以下四方面: 1、Dubbo 内核之 Filter

Spring Web Reactive Framework Multipart File Issue

不羁的心 提交于 2019-12-04 06:54:35
I'm trying to implement and image upload using Spring's Reactive Framework by trying the following: @RestController @RequestMapping("/images") public class ImageController { @Autowired private IImageService imageService; @PostMapping(value = "", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) Mono<ImageEntity> saveImage(@RequestBody Mono<FilePart> part) throws Exception{ return part.flatMap(file -> imageService.saveImage(file)); } } But I keep getting a 415 with the following error message: Response status 415 with reason "Content type 'multipart

RxJS - take n last elements from an observable

心已入冬 提交于 2019-12-04 02:08:39
I want to take 3 last elements from an observable. Let's say that my timeline looks like this: --a---b-c---d---e---f-g-h-i------j-> where: a, b, c, d, e, f, g, h, i, j are emitted values Whenever a new value is emitted I want to get it immediately, so it can look like this: [a] [a, b] [a, b, c] [b, c, d] [c, d, e] [d, e, f] [e, f, g] [f, g, h] ... and so on I think that this is super useful. Imagine building a chat where you want to display 10 last messages. Whenever a new message comes you want to update your view. My attempt: demo You can use scan for this: from(['a', 'b', 'c', 'd', 'e', 'f'

聊聊reactive streams的backpressure

耗尽温柔 提交于 2019-12-03 19:26:29
序 本文主要研究下reactive streams的backpressure reactive streams跟传统streams的区别 @Test public void testShowReactiveStreams() throws InterruptedException { Flux.interval(Duration.ofMillis(1000)) .take(500) .subscribe(e -> LOGGER.info("get {}",e)); Thread.sleep(5*60*1000); } 输出实例如下: 18:52:34.118 [main] DEBUG reactor.util.Loggers$LoggerFactory - Using Slf4j logging framework 18:52:35.157 [parallel-2] INFO com.example.demo.FluxTest - get 0 18:52:36.156 [parallel-2] INFO com.example.demo.FluxTest - get 1 18:52:37.156 [parallel-2] INFO com.example.demo.FluxTest - get 2 18:52:38.159 [parallel-2] INFO com.example

reactor-rabbitmq小试牛刀

折月煮酒 提交于 2019-12-03 13:07:12
序 本文主要研究一下如何使用reactor-rabbitmq maven <dependency> <groupId>io.projectreactor.rabbitmq</groupId> <artifactId>reactor-rabbitmq</artifactId> <version>1.0.0.M2</version> </dependency> rabbitmq 参考 docker搭建rabbitmq集群 当前使用的镜像是bijukunjummen/rabbitmq-server:3.7.0,docker-compose文件配置的账号密码为myuser/mypass 访问 http://192.168.99.100:15672可以查看界面 实例 @Test public void testProducer() throws InterruptedException { int count = 100; ConnectionFactory connectionFactory = new ConnectionFactory(); connectionFactory.useNio(); connectionFactory.setUsername("myuser"); connectionFactory.setPassword("mypass"); SenderOptions

Why does Spring not provide reactive (non-blocking) clients for relational databases?

╄→尐↘猪︶ㄣ 提交于 2019-12-03 09:28:09
问题 I've used Vert.x toolkit for creating reactive applications with support for relational DBs like MySQL and Postgres. I know Spring provides reactive support for some NoSQL DBs like Cassandra and Mongo but are they willing to provide the same for relational DBs? 回答1: What's the idea behind the Spring Framework? Spring Framework is a library to improve developer productivity, and so are Spring's portfolio projects such as Spring Data, Spring Security, Spring Cloud. These projects build on top

Mono switchIfEmpty() is always called

馋奶兔 提交于 2019-12-03 07:22:43
问题 I have two methods. Main method: @PostMapping("/login") public Mono<ResponseEntity<ApiResponseLogin>> loginUser(@RequestBody final LoginUser loginUser) { return socialService.verifyAccount(loginUser) .flatMap(socialAccountIsValid -> { if (socialAccountIsValid) { return this.userService.getUserByEmail(loginUser.getEmail()) .switchIfEmpty(insertUser(loginUser)) .flatMap(foundUser -> updateUser(loginUser, foundUser)) .map(savedUser -> { String jwts = jwt.createJwts(savedUser.get_id(), savedUser

Mono switchIfEmpty() is always called

和自甴很熟 提交于 2019-12-03 02:32:11
I have two methods. Main method: @PostMapping("/login") public Mono<ResponseEntity<ApiResponseLogin>> loginUser(@RequestBody final LoginUser loginUser) { return socialService.verifyAccount(loginUser) .flatMap(socialAccountIsValid -> { if (socialAccountIsValid) { return this.userService.getUserByEmail(loginUser.getEmail()) .switchIfEmpty(insertUser(loginUser)) .flatMap(foundUser -> updateUser(loginUser, foundUser)) .map(savedUser -> { String jwts = jwt.createJwts(savedUser.get_id(), savedUser.getFirstName(), "user"); return new ResponseEntity<>(HttpStatus.OK); }); } else { return Mono.just(new

How to check if Mono is empty?

只谈情不闲聊 提交于 2019-12-02 22:54:39
I'm developing a app with Spring Boot 2.0 and Kotlin using the WebFlux framework. I want to check if a user id exits before save a transaction. I'm stucked in a simple thing like validate if a Mono is empty. fun createTransaction(serverRequest: ServerRequest) : Mono<ServerResponse> { val transaction = serverRequest.body(BodyExtractors.toMono(Transaction::class.java)) transaction.flatMap { val user = userRepository.findById(it.userId) // If it's empty, return badRequest() } return transaction.flatMap { transactionRepository.save(it).then(created(URI.create("/transaction/" + it.id)).build()) } }

How to pass data from delegate method to the observable's onNext method in RxSwift?

元气小坏坏 提交于 2019-12-02 12:29:45
I have manager class which will connect and manage the data and state of the Bluetooth device. The manager class conforms to IWDeviceManagerDelegate and has a method which gives the weight data func onReceiveWeightData(_ device: IWDevice!, data: IWWeightData!) . Once I call listenToWeight() from any controller I want to give the data using Observable. How I fire an onNext event with the data of onReceiveWeightData method to listenToWeight observable? Below is the code. class WeightMachineManager: NSObject { func setup() { IWDeviceManager.shared()?.delegate = self IWDeviceManager.shared()?