【问题标题】:JMS message sent in Gatling, but reply not received - Where am I going wrong?在 Gatling 中发送 JMS 消息,但未收到回复 - 我哪里出错了?
【发布时间】: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 的消息@,因此永远不会收到响应,并且永远不会进行检查。

我确定我错过了一些简单的东西 - 但它是什么?!

【问题讨论】:

    标签: jms gatling


    【解决方案1】:

    您确定您有一个从 repQueue 读取然后在 repQueue 中写入响应消息的示例 AUT? 如果没有,加特林只是在等待永远不会到达的响应。

    【讨论】:

    • 正如我所说,“我确定我错过了一些简单的东西”......我现在会感到尴尬!谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-12
    • 2014-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多