如何打印 Gattle JMS 请求回复
我是加特林世界的新手,我尝试使用加特林 JMS 支持向 TIBCO EMS(企业消息服务)发送消息。我能够发送消息,但我不知道如何打印请求回复。
对于http请求,我只需在logback-test.xml中取消注释这一行:
这是我的设置对于加特林 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%)
任何人都可以帮助我吗有关如何打印请求回复的信息? :)
I am new in gatling world and i tried to send messages to TIBCO EMS(Enterprise Message Service) using gatling JMS support. I was able to send the messages but i have no idea how can i print the request reply.
For http requests i just uncomment in logback-test.xml this line:
<logger name="io.gatling.http.engine.response" level="TRACE" />
This is my setup for 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))
}
When i run the above code i get only this:
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%)
================================================================================
I also tried to check with simpleCheck()
method:
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
}
}
}
But when i check, it's simply fail the test and i don't see why...
---- Requests ------------------------------------------------------------------
> Global (OK=0 KO=5 )
> My test (OK=0 KO=5 )
---- Errors --------------------------------------------------------------------
> JMS check failed 5 (100.0%)
Can anyone help me with information about how can i print the request reply? :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了解决方案:
添加
src/test/resources/logback-test.xml
下一行:I found the solution:
add in
src/test/resources/logback-test.xml
the next line: