Publishing messages to ActiveMQ using Gatling

和自甴很熟 提交于 2020-01-03 18:58:21

问题


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)         
    }

Following is the exception was thrown :

java.lang.SecurityException: Invalid username:  null or empty

回答1:


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 !



来源:https://stackoverflow.com/questions/37980175/publishing-messages-to-activemq-using-gatling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!