scala - 使用 Gatling 将消息发布到 ActiveMQ

标签 scala jms activemq performance-testing gatling

我一直在用加特林将消息发布到 ActiveMq 服务器。我收到 “java.lang.SecurityException:无效的用户名:空或空”我使用有效的用户名和密码。这是我的测试代码并抛出了异常。有关如何解决此问题的任何意见都会有所帮助。

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)

我编辑了上面的代码以反射(reflect)相同的情况。
快乐加特林!

关于scala - 使用 Gatling 将消息发布到 ActiveMQ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37980175/

相关文章:

java - 创建动态 mbean 分层树的简单方法?

json - 解析json时由于输入结束而没有要映射的内容

java - 使用消息选择器按时间戳进行 JMS 过滤

java - ActiveMQConnectionFactory 发送超时

activemq - 禁用 ActivemMQ 消息的 DLQ 和重新传递

scala - 类型类和带有单例类型/案例对象的隐式

使用带有泛型类型接口(interface)的 Java 库时的 Scala 编译问题

xml - 通过 JMS 发送 JSON 对象?

java - 哪些 Java/设计模式可用于长时间运行的同步进程?

jms - 低延迟消息队列