Tag: 反应堆

Spring WebFlux:只有一个连接接收用户允许

我正在用Spring 5 Webflux和Kotlin编写一个简单的应用程序。 我正在尝试以下列方式实现PUT端点: PUT(“/confs/{id}”, { val id = it.pathVariable(“id”) ServerResponse.ok().body(service.save(it.bodyToMono(Item::class.java)), Item::class.java) }) 保存技巧是我尝试从项目中读取城市名称,解析地理坐标,在原始项目中覆盖它们,然后使用Spring Data Mongo Reactive回购保存到Mongo。 fun save(item: Mono): Mono { val geo = item.flatMap { val city = it.location?.city ?: “Somewhere” geoService.resolveGeoFromCity(city) } val zipped = item.zipWith(geo) .map { it.t1.location?.geo = it.t2 it.t1 } return repo.saveAll(zipped) .toMono() } 解析地理坐标的代码在这里: @Service class GeoService() { […]