使用Gatling将消息发布到ActiveMQ [英] Publishing messages to ActiveMQ using Gatling
本文介绍了使用Gatling将消息发布到ActiveMQ的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在使用加特林将消息发布到ActiveMq服务器.我收到"java.lang.SecurityException:无效的用户名:null或空" ,我使用了有效的用户名和密码.这是我的测试代码,抛出了异常.关于如何解决此问题的任何输入都将有所帮助.
I have been using Gatling to publish messages to ActiveMq server. I get "java.lang.SecurityException: Invalid username: null or empty" tho I use valid username and password. Here is my test code and the exception were thrown. Any inputs on how to fix this will be of help.
import io.gatling.core.Predef.Simulation
import io.gatling.core.Predef._
import io.gatling.jms.Predef._
import io.gatling.core.config.Credentials
import org.apache.activemq.ActiveMQConnectionFactory
import org.apache.activemq.jndi.ActiveMQInitialContextFactory
import javax.jms._
class WebProducer extends Simulation{
val jmsUsername:String="userName"
val jmsPwd:String="Password"
val jmsConfig = jms
.connectionFactoryName("ConnectionFactory")
.url("ssl://message01-dev.platform.net:61617")
.credentials(jmsUsername,jmsPwd)
.disableAnonymousConnect
.contextFactory(classOf[org.apache.activemq.jndi.ActiveMQInitialContextFactory].getName)
.listenerCount(1)
.usePersistentDeliveryMode
.receiveTimeout(6000)
val scn = scenario("JMS DSL test").repeat(1) {
exec(jms("req reply testing").
reqreply
.queue("YourJMSQueueName")
.replyQueue("YourJMSQueueName")
.textMessage("payload To be posted")
.property("company_id", "1234598776665")
.property("event_type","EntityCreate")
.property("event_target_entity_type","Account")
)
}
setUp(scn.inject(atOnceUsers(1)))
.protocols(jmsConfig)
}
以下是引发的异常:
java.lang.SecurityException: Invalid username: null or empty
推荐答案
好,我在添加两件事的同时进行了此工作:
Ok, I got this working adding two things :
- .disableAnonymousConnect after .credentials(jmsUsername,jmsPwd)
- .replyQueue(jmsQueueName) after .queue(jmsQueueName)
我编辑了上面的代码以反映相同的内容. 加特林快乐!
I edited the above code to reflect the same. Happy Gatling !
这篇关于使用Gatling将消息发布到ActiveMQ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文