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 ( and especially Expression Language ( Then, read up on Checks ( 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 ("$.header.Action").toString.equals("tokenized_tap")) { 
       matcher ="$.CardData.Token").toString"Received tokenized_tap for token " + matcher)
    } else if ("$.header.Action").toString.equals("funds_result")) {
      matcher ="$.FundsResult.Token").toString"Received funds_result for token " + matcher)
    } else {
      matcher = msg.asInstanceOf[TextMessage].getText"Ignore message with type " +"$.header.Action").toString)
      if("$.header.Action").toString.equals("error")){"Error message details" + matcher)
      logger.debug("Ignore message " + matcher)

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