Consume response of mqtt subscribed topic

Hi all,

how can I read/access the response data of any mqtt subscribed topic?

I’m not sure to understand your use case.

If I correctly understand, you have a virtual user that create a mqtt connection and subscribe to different topic and you don’t know on which subscribed topic the response will be?

Cheers!

I wanted to transform the response body stream received on a subscribed topic, because the transmitted data are google protobuf encoded

Two steps process:

  • Make sure your project is able to generate the required classes from your .proto files (depends on the build, i.e. maven, scala, gradle)
  • From your generated Java/Scala objects, you can use the static method parseForm, which takes a array of bytes and converts it to the proper type:
mqtt("subscribe").subscribe("topic")
    .await(10)
    .check(
        bodyBytes().transform(GeneratedClass.parseForm).is(someVariable)
    )

Note: fixed a typo in previous post: equals => is.

thx, it’s working! :grinning: