emqx / mqtt-jmeter

MQTT JMeter Plugin
https://www.emqx.com/en
Apache License 2.0
454 stars 196 forks source link

MQTT Sub Sampler: Timeout Option for Sample on 'Number or received messages' #125

Open br41nst0rm opened 2 years ago

br41nst0rm commented 2 years ago

Hi, i think a timeout option is missing in the 'MQTT Sub Sampler' with SampleOnCondition set to 'Number or received messages'. It basicly deadlocks a thread when awaited messages never arrive, or, respectively, was not send back in the first place ..for who knows what reasons.

With our customer we have usecases were we need to measure the time it takes from publishing a messages and receiving a response on different topics (with processing backends involved).

Script would do something like this: thread1 publishes a message on topic1 -> a backend system receive and processes the message and sends a message/response to topic2 -> thread1 meanwhile subscribed to topic2 and waits for that message/response.

We want to be able to at least measure the time from publishing the message on topic1 to receiving the response on topic2. Considering the backend could also have issues and may not send a response at all, which would be a problematic situation which needs to be handled like an error. But, when thread1 that subscribed to topic2 would then wait basically forever for that one message/response to arrive and those the thread actually is caught in a deadlock situation and no error is logged.

So, for that, I think the easiest thing is to implement a [optional] timeout option, were, when the sampler runs into that timeout the sampler fails and reports an error.

Thats what i've done, Please have a look

Regards

SampleOnCondition: 'Number or received messages' -> timeoutTextField is enabled image If timeout is set to 0 the Sub Sampler behaves like ever before and waits for all messages to arrive (never times out)

SampleOnCondition: 'specified elapsed time (ms)' -> timeoutTextField is disabled image