Search code examples
parallel-processingjmetercontrollerjmeter-plugins

JMeter - Parallel controller transaction with dynamic name fails from second iteration


Plugin used : Parallel Controller & Sampler Controller used : Parallel Controller

Parallel controller name in script : ParaTrx2_${__Random(1,1000,uniqueID)} Above controller having 2 requests and name conataining unique id generated at controller level. We get error on console when try to run script- "java.lang.RuntimeException: Attempting to reset the thread name"

This works fine when we switch to tranaction controller. Also if we remove ${__Random(1,1000,uniqueID)} from controller name then scripts works fine for all iterations.

Is there any way to handle this scenario as we need unique id to be part of transaction name?


Solution

  • You could rename the Parallel Controller and eventually its children according to your needs using i.e. JSR223 Sampler and the code like:

    SampleResult.setIgnore()
    
    def postfix = org.apache.commons.lang3.RandomUtils.nextInt(1, 1000)
    
    prev.setSampleLabel('ParaTrx2_' + postfix)
    
    prev.getSubResults().each { subResult ->
        subResult.setSampleLabel(postfix as String)
    }
    

    Demo:

    enter image description here

    More information on Groovy scripting in JMeter: Apache Groovy: What Is Groovy Used For?