Can't get iteration number in Backend listener
sivaram-vu opened this issue · 7 comments
Any idea how we can get the iteration number in backend listener?
Hey there,
First of all thanks for reporting the issue. I will look into it as soon as I can. Might be able to access it through JMeter's context service, otherwise I might have to try and figure out a way of calculating it myself.
Cheers,
Hi @sivaram-vu,
So I'm looking into the issue right now. For now you could simply add a custom field to your listener! :) (new feature added in version 2.3.2). Here's how you could do it.
- Add a field in the backend listener
- Name it what you want (i.e : threadIteration)
- Assign the following value :
${__groovy(return vars.getIteration();)}
Thanks,
Hello @pmouawad ,
I'm requiring your assistance regarding this issue. I am unable to access the JMeter variables through the JMeterContextService.
The way I understand it is that the Backend Listener is set before the test plan is started, therefore before the threads are started. Because of that, when calling the method JMeterContextService.getContext();
I'm unable to retrieve the context since it's related to a thread in particular.
It all makes sense really, but would you happen to know if there is a way to access the variables inside a backend listener (programmatically that is, not like the method listed above) ?
Thanks,
Hello,
You can't access JMeter variables or JMeterContextService.getContext() from a BackendListenerClient as the threads of VU are different from Listener thread.
What is the use case behind this particular issue ?
@pmouawad Thank you for responding. That's what I thought and it totally makes sense. As for the use case, we'd have to ask @sivaram-vu.
Anyways, since this is impossible to achieve from within the plugin's code, the only way to achieve this behaviour would be through the solution I described above. If it doesn't work, then I'm afraid it's impossible to achieve at all.
Thanks everyone, I'll be closing this issue since there's nothing more we can do. Although feel free to keep the conversation going.
Thank you for responding.
I just wanted to check if I can pass user variables to DB for the reporting purposes.
For example, Order created in the iteration need to be logged in to DB.
I feel fields in backend listener also can not access user variables as they simply do not exist in the context of backend listener.
Hi @sivaram-vu ,
I've been able to access variables from the Test Plan & from a CSV (loaded before thread groups). But indeed unable to access variables that are scoped within thread groups (whether they're dynamic or not). It it in fact due to the way JMeter works and there is nothing I can do on my end to allow this
A work around could be for you to put the listener's test mode in "debug" and have a JSR223 sampler (or a Dummy Sampler) logging the details in the request body. It's not pretty but it works.
Thanks,