You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Akos Gabriel <ak...@gmail.com> on 2020/04/22 20:17:34 UTC

sampleEnd called twice

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

Re: sampleEnd called twice

Posted by "glinius@live.com" <gl...@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: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org