是否保证在基于 temp-topic 的 request/response 方案中处理请求之前建立响应订阅?
Is it guaranteed that subscription for response is established before request is processed in temp-topic based request/response scheme?
我想在以下部分实施 request/response 模式:
- 服务器: 带 ActiveMQ 的 Springboot
- 客户端: JavaScript 在 websocket 上使用 stompjs
我想要像 http 请求这样的行为。
发送请求,得到相应的响应。
我尝试使用临时频道来做到这一点
我发送了 3 条消息
步骤是:
订阅临时频道
SUBSCRIBE
id:mysub
destination:/temp-queue/example
发送请求并在步骤 1
的订阅频道中包含 reply-to header
destination:/queue/PO.REQUEST
reply-to:/temp-queue/example
从服务器获取响应消息
MESSAGE
subscription:foo
reply-to:/queue/temp.default.23.example
destination:/queue/PO.REQUEST
reply-to:/temp-queue/example
但是现在(作为客户端异步发送消息)我不确定步骤 1 是否已在服务器上完成,因此当步骤 2 的请求到达服务器时服务器已准备好向 queue 发送响应.
是否有可能服务器在完成步骤 1 之前完成了步骤 2,因此将响应发送到无处可去?或者 ActiveMQ 是否确保从客户端收到的消息 1 和 2 以正确的顺序处理和完成?
消息 1 和 2 之间是否会出现竞争条件?
非常感谢!
您的客户端发送的任何 STOMP 帧都可以与接收请求一起发送,使该帧的处理同步。因此,如果您想确保订阅在发送之前完成,请在继续发送之前附加一个 receipt-id to the subscribe frame and wait for the spec mandated RECEIPT 帧,这可确保您的订阅在任何其他处理之前设置。
我想在以下部分实施 request/response 模式:
- 服务器: 带 ActiveMQ 的 Springboot
- 客户端: JavaScript 在 websocket 上使用 stompjs
我想要像 http 请求这样的行为。
发送请求,得到相应的响应。
我尝试使用临时频道来做到这一点 我发送了 3 条消息
步骤是:
订阅临时频道
SUBSCRIBE id:mysub destination:/temp-queue/example
发送请求并在步骤 1
的订阅频道中包含 reply-to headerdestination:/queue/PO.REQUEST reply-to:/temp-queue/example
从服务器获取响应消息
MESSAGE subscription:foo reply-to:/queue/temp.default.23.example destination:/queue/PO.REQUEST reply-to:/temp-queue/example
但是现在(作为客户端异步发送消息)我不确定步骤 1 是否已在服务器上完成,因此当步骤 2 的请求到达服务器时服务器已准备好向 queue 发送响应.
是否有可能服务器在完成步骤 1 之前完成了步骤 2,因此将响应发送到无处可去?或者 ActiveMQ 是否确保从客户端收到的消息 1 和 2 以正确的顺序处理和完成?
消息 1 和 2 之间是否会出现竞争条件?
非常感谢!
您的客户端发送的任何 STOMP 帧都可以与接收请求一起发送,使该帧的处理同步。因此,如果您想确保订阅在发送之前完成,请在继续发送之前附加一个 receipt-id to the subscribe frame and wait for the spec mandated RECEIPT 帧,这可确保您的订阅在任何其他处理之前设置。