Search code examples
jmeterperformance-testingactivemq-artemismq

JMeter parallel mq publishing request messages with unique sequence ID which needs to be validated against external system before being sent


I need to create some load test of Publishing messages onto a system which takes input through an ActiveMQ Artemis Queue. The problem I have is that each request I send must have a unique sequence number in order to be considered valid and the system behind the queue manages this number in a DB and will not consider a valid request if the current thread request has a message with a different id that what the system is expecting.

I was thinking that this approach below would be a possible solution, but I wanted to get some validation from the community if my approach would be correct or not and maybe some suggestion.

Set-up thread group:
    1. : Get initialSequenceID from DB through JDBC sampler 
    2. Pass initialSequenceID to JMeter system variables
    
Thread group: 
(test with 1 loop, 3 parallel threads):
    3. User Defined Variables: get initialStartingCounterValue from jmeter system variables
    4. JMeter Counter (config element): initialize global counter with initialSequenceID (using Jmeter global counter) and create a threadCounterVariable. 

Now for this part I am having trouble but basically this is how I am thinking to logically implement it:

A. Spawn X parallel Publisher threads with uniqueCounterValue starting from initialStartingCounterValue (refer Jmeter global counter variable) - I tested this and it works with the JMeter Publisher sampler (the counter value ids are unique per each request even though the threads are parallel)
For each thread attempting to publish:
    B. Ask db if the next id has incremented to the current thread value
    C. Compare currentThreadUniqueCounterValue with currentDbSequenceId
    if (currentThreadUniqueCounterValue == currentDbSequenceId) {
        send publish request
    } else {
        retry until currentThreadUniqueCounterValue == currentDbSequenceId or some_timeout_value
    }

Basically, each thread (having a unique sequence number) needs to ask the Db if it is ready to accept a message with its current id which is set by the JMeter global counter.

This A, B, C par is giving me headaches. Any thoughts or suggestions of how I should implement this would be greatly appreciated.


Solution

  • The easiest would be:

    1. setUp Thread Group:

      • Get initialSequenceID from DB through JDBC sampler
      • Generate as many "sequence IDs" as needed and write them into a CSV file using JSR223 Sampler and Groovy language
    2. "Normal" Thread Group

      • Use CSV Data Set Config to read sequence ID values from the CSV file until they're available or your test ends somehow else (last thread finishes last iteration, test duration exceeded, etc.)