【发布时间】:2020-10-21 16:31:11
【问题描述】:
我正在开发一个 springboot 反应式 API 来从 couchbase 数据库中获取更新的结果。我有一个基于 N1QL 的存储库,如下所示。
@Repository
@N1qlPrimaryIndexed
public interface LocationDataRepository extends ReactiveCrudRepository<LocationData,String> {
@Query("#{#n1ql.selectEntity} where userID=$1 and dataType = $2")
Flux<LocationData> findByUserIDAndDataType(String userID,String dataType);
}
下面是我的restful webcontroller方法。
@Autowired
LocationDataRepository locationDataRepository;
@GetMapping(value="/LocationUpdates", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public Flux<LocationData> findLatestLocations(@RequestParam("userID") String userID){
String dataType = "location";
return Flux.interval(Duration.ofSeconds(1)).flatMap(X -> locationDataRepository.findByUserIDAndDataType(userID,dataType));
}
我的问题是,当我从浏览器或邮递员点击此端点时,它不会显示任何结果,但会保持刷新。我如何能够使用 LocationRepository 保存数据。我无法弄清楚这里有什么问题。谁可以帮我这个事?谢谢。
【问题讨论】:
标签: java couchbase spring-webflux spring-data-couchbase