JMS Message Matching

Hey Everyone,

I want to test a JMS service. However, the reply queue sends a different constructed XML message than the one sent to to the request queue. Is there a way in Gatling to match a field in the request message’s body with the same field in the response message’s body? Any help would be great.

Short answer is yes, Gatling can do that.

Start by reading up on Sessions (https://gatling.io/docs/current/session/) and especially Expression Language (https://gatling.io/docs/current/session/expression_el#expression-language). Then, read up on Checks (https://gatling.io/docs/current/http/http_check) paying particular attention to xpath. Once you have a basic understanding of the tools that Gatling provides you, if you have a specific question, ask.

Hi Ali,

We use custom Matcher to achieve this

object SQSMatcher extends JmsMessageMatcher {
  private val logger = LoggerFactory.getLogger(classOf[TapsToWhisperSimulation])

  override def prepareRequest(msg: Message): Unit = {}

  override def responseMatchId(msg: Message): String = getIdFromResponse(msg)

  override def requestMatchId(msg: Message): String = getIdFromRequest(msg)

  def getIdFromResponse(msg: Message): String = try {
    val dc = JsonPath.parse(msg.asInstanceOf[TextMessage].getText)
    var matcher: String = ""
    if (dc.read("$.header.Action").toString.equals("tokenized_tap")) { 
       matcher = dc.read("$.CardData.Token").toString
       logger.info("Received tokenized_tap for token " + matcher)
    } else if (dc.read("$.header.Action").toString.equals("funds_result")) {
      matcher = dc.read("$.FundsResult.Token").toString
      logger.info("Received funds_result for token " + matcher)
    } else {
      matcher = msg.asInstanceOf[TextMessage].getText
      logger.info("Ignore message with type " + dc.read("$.header.Action").toString)
      if(dc.read("$.header.Action").toString.equals("error")){
        logger.info("Error message details" + matcher)
      }
      logger.debug("Ignore message " + matcher)
    }
    matcher
  }

Thanks for the help John and Maria. Really solved my problem and made things easier.