SSE: How to check message on unmatched messages in buffer

I’m trying to figure out how to set a check on unmatched messages.

I have something similar to:

sse("SSE").get("/events")
    .await(10).on(
        sse.checkMessage("Old events present")
            .check(substring("OLD_EVENT"))
    )

http("add event")
    .post("/event")
    .body(StringBody(json))
    .asJson()
sse.setCheck()
    .await(10).on(
        sse.checkMessage("Check for event")
            .check(substring("NEW_CONTENT"))
    )

This fails because the SSE event occurred before the setCheck command executed. I can see the event in ws.processUnmatchedMessages. Is there a way to get the setCheck command to also run on the unmatchedMessages? Something like:

sse("check").setCheck()
    .await(10).on(
        sse.checkMessage("new check")
            .includeMessagesInBuffer(true)
            .check(substring("NEW_EVENT"))
    )

That’s currently not possible.
Your suggestion is welcome though, maybe that’s something we’ll investigate for a future version.

Ok thanks. What is the recommended solution to connect to an SSE stream, fire an http event, and then check the responses?

processUnmatchedMessages

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.