成功执行了JMS Gatling脚本后,我遇到了错误:
Gatling: There were no requests sent during the simulation, reports won't be generated
我尝试了HTTP请求,并且可以正确生成报告。但是,对于JMS报告不会生成。
消息正确产生并且被消耗。
摘自Gatling sample的实际脚本:
package com.msg.demo
import io.gatling.core.Predef._
import io.gatling.jms.Predef._
import javax.jms._
import scala.concurrent.duration._
import io.gatling.core.feeder.SourceFeederBuilder
import io.gatling.core.structure.ChainBuilder
import java.util.UUID
class TestJmsDsl extends Simulation {
// create a ConnectionFactory for ActiveMQ
// search the documentation of your JMS broker
val connectionFactory =
new org.apache.activemq.ActiveMQConnectionFactory("tcp://localhost:61616")
val jndiBasedConnectionFactory = jmsJndiConnectionFactory
.connectionFactoryName("ConnectionFactory")
.url("tcp://localhost:61616")
.credentials("user", "secret")
.contextFactory("org.apache.activemq.jndi.ActiveMQInitialContextFactory")
val jmsConfig = jms
.connectionFactory(connectionFactory)
.usePersistentDeliveryMode
val scn = scenario("JMS DSL test").repeat(0){
exec(jms("req reply testing").requestReply
.queue("jmstestq")
.replyQueue("jmstestq")
.textMessage("HELLO FROM GATLING JMS DSL")
.property("test_header", "test_value")
.jmsType("test_jms_type")
.check(simpleCheck(checkBodyTextCorrect)))
}
setUp(scn.inject(constantUsersPerSec(1) during (5 seconds)))
.protocols(jmsConfig)
.assertions(global.successfulRequests.percent.gte(10))
def checkBodyTextCorrect(m: Message) = {
// this assumes that the service just does an "uppercase" transform on the text
m match {
case tm: TextMessage => true //tm.getText == "HELLO FROM GATLING JMS DSL"
case _ => false
}
}
}
我能够找到解决方案。解决方案位于:https://github.com/gatling/gatling/blob/master/gatling-jms/src/test/scala/io/gatling/jms/compile/JmsCompileTest.scala
向jms添加以下方法解决了这个问题:.messageMatcher(HeaderMatcher).matchByCorrelationId