jms - Gatling:模拟期间没有发送请求,不会生成报告
问题描述
成功执行 JMS Gatling 脚本后,我遇到了错误:
Gatling: There were no requests sent during the simulation, reports won't be generated
我尝试了 HTTP 请求,它正在正确生成报告。但是,对于 JMS 报告不会生成。
消息正在正确生成并被消耗。
取自Gatling 示例的实际脚本:
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
推荐阅读
- python - 如何将表单动态添加到 Django 表单集?
- amazon-web-services - 从 AWS EC2 和负载均衡器上的端口 80 到 8000
- maven - Maven 在子版本中使用父变量
- ios - 通过 Xcode 安装 iOS 应用程序会提供旧事务
- c - 更改字符指针中的值会导致空白或问号
- c++ - 在 VC++ 中找不到 ascii 字符串的 _assert()
- javascript - 将两个对象数组与 v8 和过滤器/查找进行比较的高性能方法
- c++ - Segmentation fault on using Eigen::MatrixXf as function return type
- c# - c# Finishing a BPF(Business Process Flow)
- html - 如何将图像放在 Matlab uicontrol 按钮上?