是否可以编写一个gatling脚本,该脚本连接到WebSocket,然后在收到某些消息时执行操作(例如新的HTTP请求)(最好是对STOMP消息具有开箱即用的支持,但我可能可以解决此问题。)
换句话说,应该尽可能地模拟“真实客户”。真正的客户端(角度应用程序)将基于某些WebSocket消息加载数据。
我正在寻找类似于(伪代码,不起作用)的东西:
val scn = scenario("WebSocket")
.exec(http("Home").get("/"))
.pause(1)
.exec(session => session.set("id", "Steph" + session.userId))
.exec(http("Login").get("/room?username=${id}"))
.pause(1)
.exec(
ws("Connect WS")
.open("/room/chat?username=${id}")
// ---------------------------------------------------------------------
// Is it possible to trigger/exec something (http call, full scenario)
// as reaction to a STOMP/WebSocket message?
.onMessage(check(perform some check, maybe regex?).as("idFromPayload"))
.exec(http("STOMP reaction").get("/entity/${idFromPayload}"))
// ---------------------------------------------------------------------
)
.exec(ws("Close WS").close)
// ideally, closing the websocket should only be done once the full scenario is over
// (or never, until the script terminates in "forever" scenarios)
这当前可行吗?如果没有,这是否计划用于未来的加特林?