sampleEnd called twice

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

sampleEnd called twice

Akos Gabriel
Hi,

Problem description:
I have an MQ-based system which I would like to performance-test with the
following steps:

1. send JMS message to q1 (record its jms timestamp and messageId in a
hashmap)
2. message will be read by the app and replied into another queue,
correlationId set
3. read reply queue, find the correlated message and calculate roundtrip
time

1. and 3. are in separate thread groups, written in JSR223 Groovy

Code snippet:

     if (sendtime>0) {
      dt=recvtime - sendtime;
      log.info(" -> roundtrip time: "+dt);
      SampleResult.setResponseCode("200");
      SampleResult.setSuccessful(true);
      SampleResult.setStartTime(sendtime);
      SampleResult.setEndTime(recvtime);

roundtrip time (dt) is calculated correctly and logged.
However I would like to have graphs drawn about dt by JMeter.
I thought I would like to use this second sampler to draw the graphs.

But the last line of code causes the exception:

2020-04-22 21:49:40,809 ERROR o.a.j.s.SampleResult: sampleEnd called twice
java.lang.Throwable: Invalid call sequence
...

Please help me how to solve the problem.

Thanks,
Akos
Reply | Threaded
Open this post in threaded view
|

Re: sampleEnd called twice

glinius@live.com
The correct solution would be storing your *dt* into a JMeter Variable like:


> vars.put('dt', dt as String)

then you can declate this *dt* as a  Sample Variable
<https://jmeter.apache.org/usermanual/listeners.html#sample_variables>   and
generate a custom graph over
<https://jmeter.apache.org/usermanual/generating-dashboard.html#customs_graphs>
time out of it

If it's too complex you can update your JSR223 Sampler execution time from
the JSR223 PostProcessor like:


> prev.elapsedTime = vars.getObject('dt') as long

See  Top 8 JMeter Java Classes You Should Be Using with Groovy
<https://www.blazemeter.com/blog/top-8-jmeter-java-classes-you-should-be-using-with-groovy>  
article for more information regarding what these *vars* and *prev* stand
for and remember each time you bypass JMeter limitation using reflection
somewhere somehow a kitten dies.



--
Sent from: http://www.jmeter-archive.org/JMeter-User-f512775.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]