0
サーバーサイドイベント経由でストリーミングデータを受信する方法Content-Type: text/event-stream
Spring Flux機能を使用していますか? WebClientでこのような応答を処理することは可能ですか?Springリアクティブ処理サーバーのサイドイベント
ソースエンドポイント:
@GetMapping(path = "/", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public Flux<CurrencyStats> get() {
return getStream();
}
私は、データをそのようを取得しようとしましたが、間違っているようです。私は必要なものである
WebClient webClient = WebClient.create("http://example.com");
return webClient
.get()
.uri("/sse")
.accept(MediaType.TEXT_EVENT_STREAM)
.retrieve()
.bodyToFlux(String.class).doOnNext(
string -> {
// print that string
}
);