【问题标题】:spring boot rsocket with "message was successfully sent"带有“消息已成功发送”的spring boot rsocket
【发布时间】:2021-04-12 16:05:35
【问题描述】:

我有一个客户端需要从服务器接收异常

客户:

rSocketRequester
    .route("v1.data")
    .data(data)
    .sendAndAwait()

服务器:

return Mono.error(RuntimeException("test excep"))

在文档中说:https://docs.spring.io/spring-framework/docs/current/reference/html/web-reactive.html#rsocket-requester-requests“对于 Fire-and-Forget,请使用返回 Mono 的 send() 方法。请注意,Mono 仅表示消息已成功发送,而不是已处理。”

如何获取消息完整或异常数据?

【问题讨论】:

    标签: spring-boot kotlin rsocket


    【解决方案1】:

    切换到 Request-Response 操作而不是 Fire-and-Forget,您可能希望假设结果是轻量级结果对象或空字节。

    https://github.com/spring-projects/spring-framework/blob/3ed8813bbfc1678de73529a882ce535e2636519c/src/docs/asciidoc/rsocket.adoc

    Java

    Mono<AirportLocation> location = requester.route("find.radar.EWR"))
        .retrieveMono(AirportLocation.class);
    

    科特林

    import org.springframework.messaging.rsocket.retrieveAndAwait
    
    val location = requester.route("find.radar.EWR")
        .retrieveAndAwait<AirportLocation>()
    

    【讨论】:

    • 我想过,但它就像 HTTP 状态码。 Fire-and-Forget 可以返回 Mono。我认为需要正确配置客户端,仅此而已。
    • 是的,但您不会发现远程故障。只是那个客户发送了请求。
    猜你喜欢
    • 1970-01-01
    • 2018-10-05
    • 1970-01-01
    • 2020-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多