【发布时间】:2015-11-09 09:46:43
【问题描述】:
我在 Spring @Controller 上有以下方法:
@MessageMapping("/comment/{id}")
@SendTo("/topic/conversation/{id}")
public OperationResult<Comment> comment(Comment comment) throws Exception {
//call @Service to add comment
OperationResult<Comment> operationResult = commentService.comment(comment);
return operationResult;}
即使操作不成功(operationResult.success == false),这也会向所有订阅者发送更新。
注意: OperationResult 有一个名为“success”的布尔字段来指示操作是否成功。
问题: 我想了解如何仅在操作成功(不引发异常)的情况下向订阅者发送更新,并确保发送评论的客户端始终获得 operationResult
【问题讨论】:
标签: java spring-mvc spring-websocket sockjs java-websocket