加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-16 08:45:13 所属栏目:安全 来源:网络整理
导读:我一直在使用Gatling向ActiveMq服务器发布消息.我得到“ java.lang.SecurityException:无效的用户名:null或空”我使用有效的用户名和密码.这是我的测试代码,抛出了异常.关于如何解决这个问题的任何意见都会有所帮助. import io.gatling.core.Predef.Simula
我一直在使用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)

我编辑了上面的代码以反映相同的内容.快乐的加特林!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读