ApiGateway WebSockets - Are the responses sentby integration response route, guaranteed to be in same order than the sent messages?

0

Hi, I try to get a way to verify if my messages were properly handled by ApiGatwayso that i can resend them if a connectiontimeout is triggered. as overriding requestId may not be possible with ApiGateway WebSockets (i posted another question related to that) i thought that relying on order of messages could help. As i already have a ApiGateway response route,sent by service response (i use SQS behin websocket api) i wondered if the order of the responses is guaranteed to be the same thanthe order of sent messages?

If not, what is the recommended way of handling send retries when a connection timeout triggers, or even if an unexpected close event triggers. Thanks Seb

1 回答
0

If you call the postToConnection API multiple times, there is not guarantee that the messages will get to the client in the same order. If order is important, do not send the second message until you get an ack on the first message.

profile pictureAWS
专家
Uri
已回答 1 年前
  • Thanks, but i was not thinking about postToConnection api, but more the integration reponse from ApiGateway. Maybe it uses same api in background?

  • Sorry, my bad. I thought you were referring to messages send by the backend.

    If you get two messages and send these messages to the integration for processing, and they return a response, which API GW should send back to the client, you have no control in which order the client messages will be processed, so you don't know in which order the responses will arrive back to API Gateway.

    Bottom line, you can't rely on message ordering for the responses.

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则