JMS support was initially contributed by Jason Koch.


Gatling JMS DSL is not available by default.

One has to manually add the following imports:

import io.gatling.jms.Predef._
import javax.jms._

JMS Protocol

Use the jms object in order to create a JMS protocol.

  • connectionFactory: mandatory, an instance of ConnectionFactory. Use jmsJndiConnectionFactory to obtain one via JNDI lookup or create it by yourself.
  • credentials: optional, to create a JMS connection
  • useNonPersistentDeliveryMode / usePersistentDeliveryMode: optional, default to non persistent
  • matchByMessageID / matchByCorrelationID / messageMatcher: specify how request and response messages should be matched, default to matchByMessageID. Use matchByCorrelationID for ActiveMQ.
  • replyTimeout: optional reply timeout, in milliseconds, default is none

JMS JNDI Connection Factory

Use jmsJndiConnectionFactory object to obtain an instance of JMS ConnectionFactory via JNDI lookup.

  • connectionFactoryName: mandatory
  • url: mandatory
  • contextFactory: mandatory
  • credentials: optional, for performing JNDI lookup
  • property: optional, custom JNDI property

JMS Request API

Use the jms("requestName") method in order to create a JMS request.

Request Type

Currently, requestReply and send (fire and forget) requests are supported.


Define the target destination with queue("queueName") or alternatively with destination(JmsDestination)

Optionally define reply destination with replyQueue("responseQueue") or replyDestination(JmsDestination) if not defined dynamic queue will be used.

Additionally for reply destination JMS selector can be defined with selector("selector")

Message Matching

Request/Reply messages are matched using JMS pattern (request JMSMessageID should be return in response as JMSCorrelationID).

If different logic is required, it can be specified using messageMatcher(JmsMessageMatcher).


  • textMessage(Expression[String])
  • bytesMessage(Expression[Array[Byte]])
  • mapMessage(Expression[Map[String, Any]])
  • objectMessage(Expression[])


One can send additional properties with property(Expression[String], Expression[Any]).

JMS Type

Jms type can be specified with jmsType(Expression[String]).


JMS checks are very basic for now.

There is simpleCheck that accepts just javax.jms.Message => Boolean functions.

There is also xpath check for javax.jms.TextMessage that carries XML content.

Additionally you can define your custom check that implements Check[javax.jms.Message]


Short example, assuming FFMQ on localhost, using a reqreply query, to the queue named “jmstestq”:

import net.timewalker.ffmq3.FFMQConstants
import io.gatling.core.Predef._
import io.gatling.jms.Predef._
import javax.jms._
import scala.concurrent.duration._

class TestJmsDsl extends Simulation {

  val connectionFactory = jmsJndiConnectionFactory
    .credentials("user", "secret")

  val jmsConfig = jms

  val scn = scenario("JMS DSL test").repeat(1) {
    exec(jms("req reply testing").requestReply
      .textMessage("hello from gatling jms dsl")
      .property("test_header", "test_value")

  setUp(scn.inject(rampUsersPerSec(10) to 1000 during (2 minutes)))

  def checkBodyTextCorrect(m: Message) = {
    // this assumes that the service just does an "uppercase" transform on the text
    m match {
      case tm: TextMessage => tm.getText == "HELLO FROM GATLING JMS DSL"
      case _ => false