【发布时间】:2020-04-02 03:00:22
【问题描述】:
我刚开始使用 Gatling 和 JMS 进行测试。从长远来看,我会寻找 Gatling 来让 JMS 侦听器等待 JMS 消息从我们的 AUT 放入队列中,但现在我只是在沙箱中玩游戏以尝试掌握 Gatling 的 JMS 处理.我一直在查看谷歌搜索向我抛出的各种示例,我想出的最好的示例如下:
package jmspublisher
import io.gatling.core.Predef._
import io.gatling.jms.Predef._
import javax.jms._
import scala.concurrent.duration._
class WebProducer 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 jmsUsername:String="admin"
val jmsPwd:String="admin"
val jmsConfig = jms
.connectionFactory(connectionFactory)
.usePersistentDeliveryMode
.matchByCorrelationId
val scn = scenario("JMS DSL test").repeat(1) {
exec(jms("req reply testing").requestReply
.queue("jmstestq")
.replyQueue("repQueue")
.textMessage("hello from gatling jms dsl")
.jmsType("textMessage")
.check(simpleCheck(checkBodyTextCorrect)))
}
setUp(scn.inject(atOnceUsers(1))).protocols(jmsConfig)
def checkBodyTextCorrect(m: Message) = {
print ("here")
print (m);
// 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
}
}
}
我可以在我的 activeMQ 控制台中看到创建了两个队列,一条消息在jmstestq 上排队,repQueue 在运行期间连接了一个侦听器 - 但repQueue 似乎从未收到来自@987654325 的消息@,因此永远不会收到响应,并且永远不会进行检查。
我确定我错过了一些简单的东西 - 但它是什么?!
【问题讨论】: