簡體   English   中英

如何打印 Gatling JMS 請求回復

[英]How to print Gatling JMS request reply

我是加特林世界的新手,我嘗試使用加特林 JMS 支持將消息發送到 TIBCO EMS(企業消息服務)。 我能夠發送消息,但我不知道如何打印請求回復。

對於 http 請求,我只是在 logback-test.xml 這一行中取消注釋:

<logger name="io.gatling.http.engine.response" level="TRACE" />

這是我的 gatling JMS 設置:

object GetEMSConn {


  val jndiBasedConnectionFactory = jmsJndiConnectionFactory
    .connectionFactoryName("FACTORY_NAME")
    .url("tibjmsnaming://JNDI-A.company-name")
    .credentials("anonymous", "xxx")
    .contextFactory("com.tibco.tibjms.naming.TibjmsInitialContextFactory")

  val jmsProtocol = jms
    .connectionFactory(jndiBasedConnectionFactory)
    //    .matchByCorrelationId
    .matchByMessageId
    .useNonPersistentDeliveryMode
    //    .usePersistentDeliveryMode
    .credentials("credentials", "password")
    .listenerThreadCount(1)
    .replyTimeout(1000.seconds)
}
object JMSScenario {

  val feedData = csv("testData/data.csv").circular

val jmsScenario = scenario("JMS DSL test")
    .repeat(5) {
      feed(feedCID)
        .exec(jms("My test")
          .requestReply
          .queue("MY_QUEUE")
          .textMessage("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope</soapenv:Body>\n</soapenv:Envelope>")
          .jmsType("SoapAction")
        )
    }
}
class JMSSimulation extends Simulation {

  private val jmsEx = JMSScenario.jmsScenario
    .inject(
      atOnceUsers(1)
    ).protocols(GetEMSConn.jmsProtocol)

setUp(
    jmsEx
  )
    .maxDuration(10.seconds)
    .assertions(global.responseTime.max.lt(5000))
}

當我運行上面的代碼時,我只得到這個:

Simulation com.simulations.JMSSimulation started...

================================================================================
2022-04-06 12:17:03                                           0s elapsed
---- Requests ------------------------------------------------------------------
> Global                                                   (OK=5      KO=0     )
> My test                                                  (OK=5      KO=0     )

---- JMS DSL test --------------------------------------------------------------
[##########################################################################]100%
          waiting: 0      / active: 0      / done: 1     
================================================================================

Simulation com.simulations.JMSSimulation completed in 0 seconds
Parsing log file(s)...
Parsing log file(s) done
Generating reports...

================================================================================
---- Global Information --------------------------------------------------------
> request count                                          5 (OK=5      KO=0     )
> min response time                                     20 (OK=20     KO=-     )
> max response time                                     46 (OK=46     KO=-     )
> mean response time                                    28 (OK=28     KO=-     )
> std deviation                                          9 (OK=9      KO=-     )
> response time 50th percentile                         24 (OK=24     KO=-     )
> response time 75th percentile                         28 (OK=28     KO=-     )
> response time 95th percentile                         42 (OK=42     KO=-     )
> response time 99th percentile                         45 (OK=45     KO=-     )
> mean requests/sec                                      5 (OK=5      KO=-     )
---- Response Time Distribution ------------------------------------------------
> t < 800 ms                                             5 (100%)
> 800 ms < t < 1200 ms                                   0 (  0%)
> t > 1200 ms                                            0 (  0%)
> failed                                                 0 (  0%)
================================================================================

我還嘗試使用simpleCheck()方法進行檢查:

object JMSScenario {

  val feedData = csv("testData/data.csv").circular

val jmsScenario = scenario("JMS DSL test")
    .repeat(5) {
      feed(feedCID)
        .exec(jms("My test")
          .requestReply
          .queue("MY_QUEUE")
          .textMessage("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope</soapenv:Body>\n</soapenv:Envelope>")
          .jmsType("SoapAction")
          .check(simpleCheck(checkBodyTextCorrect))
        )
    }

  def checkBodyTextCorrect(m: Message) = {
    // this assumes that the service just does an "uppercase" transform on the text
    print("in check \n")
    m match {
      case tm: TextMessage => tm.getText == "<"
      case _ => false
    }
  }
}

但是當我檢查時,它只是沒有通過測試,我不明白為什么......

---- Requests ------------------------------------------------------------------
> Global                                                   (OK=0      KO=5     )
> My test                                                  (OK=0      KO=5     )
---- Errors --------------------------------------------------------------------
> JMS check failed                                                    5 (100.0%)

誰能幫我提供有關如何打印請求回復的信息? :)

我找到了解決方案:

src/test/resources/logback-test.xml下一行:

<logger name="io.gatling.jms" level="TRACE"/>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM