我一直在使用Gatling将消息发布到 ActiveMq 服务器。我明白了“java.lang.SecurityException:无效的用户名:null 或空”不过我使用有效的用户名和密码。这是我的测试代码,抛出了异常。任何有关如何解决此问题的意见都会有所帮助。
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
好的,我得到了这个工作,添加了两件事:
- .disableAnonymousConnect after .credentials(jmsUsername,jmsPwd)
- .replyQueue(jmsQueueName) after .queue(jmsQueueName)
我编辑了上面的代码以反映相同的情况。
加特林快乐!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)