JMS点对点Jmeter负载测试-NoInitialContextException

时间:2018-11-15 02:33:05

标签: jmeter jms

我正在尝试使用Jmeter测试JMS,并试图在本地运行它,但始终出现错误: 响应消息:javax.naming.NoInitialContextException:无法实例化类:org.apache.activemq.jndi.ActiveMQInitialContextFactory [根异常是java.lang.ClassNotFoundException:org.apache.activemq.jndi.ActiveMQInitialContextFactory] ​​

我已经在jmeter的lib文件夹中添加了activemq-all.jar文件,该文件应该已经解决了问题,但是仍然存在。

请帮助我了解我是否缺少某些东西。谢谢。

下面是我的测试计划的jmx文件内容:

<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.0 r1840935">
  <hashTree>
    <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="JMS P2P Load Test" enabled="true">
      <stringProp name="TestPlan.comments"></stringProp>
      <boolProp name="TestPlan.functional_mode">false</boolProp>
      <boolProp name="TestPlan.tearDown_on_shutdown">true</boolProp>
      <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
      <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
        <collectionProp name="Arguments.arguments"/>
      </elementProp>
      <stringProp name="TestPlan.user_define_classpath"></stringProp>
    </TestPlan>
    <hashTree>
      <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="JMSTestPlan-P2P" enabled="true">
        <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
        <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
          <boolProp name="LoopController.continue_forever">false</boolProp>
          <stringProp name="LoopController.loops">2</stringProp>
        </elementProp>
        <stringProp name="ThreadGroup.num_threads">1</stringProp>
        <stringProp name="ThreadGroup.ramp_time">0</stringProp>
        <boolProp name="ThreadGroup.scheduler">false</boolProp>
        <stringProp name="ThreadGroup.duration"></stringProp>
        <stringProp name="ThreadGroup.delay"></stringProp>
      </ThreadGroup>
      <hashTree>
        <JMSSampler guiclass="JMSSamplerGui" testclass="JMSSampler" testname="JMS Point-to-Point" enabled="true">
          <stringProp name="JMSSampler.queueconnectionfactory">ConnectionFactory</stringProp>
          <stringProp name="JMSSampler.SendQueue">Q.REQ</stringProp>
          <stringProp name="JMSSampler.ReceiveQueue">Q.REQ</stringProp>
          <intProp name="JMSSampler.communicationStyle">0</intProp>
          <boolProp name="JMSSampler.isNonPersistent">false</boolProp>
          <boolProp name="JMSSampler.useReqMsgIdAsCorrelId">true</boolProp>
          <stringProp name="JMSSampler.timeout">2000</stringProp>
          <stringProp name="JMSSampler.jmsNumberOfSamplesToAggregate"></stringProp>
          <stringProp name="HTTPSamper.xml_data">Testing point to point</stringProp>
          <stringProp name="JMSSampler.initialContextFactory">org.apache.activemq.jndi.ActiveMQInitialContextFactory</stringProp>
          <stringProp name="JMSSampler.contextProviderUrl">tcp://localhost:61616</stringProp>
          <elementProp name="JMSSampler.jndiProperties" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
            <collectionProp name="Arguments.arguments">
              <elementProp name="queue.Q.REQ" elementType="Argument">
                <stringProp name="Argument.name">queue.Q.REQ</stringProp>
                <stringProp name="Argument.value">example.A</stringProp>
                <stringProp name="Argument.metadata">=</stringProp>
              </elementProp>
            </collectionProp>
          </elementProp>
          <elementProp name="arguments" elementType="JMSProperties">
            <collectionProp name="JMSProperties.properties"/>
          </elementProp>
          <boolProp name="JMSSampler.useResMsgIdAsCorrelId">true</boolProp>
        </JMSSampler>
        <hashTree/>
        <ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="true">
          <boolProp name="ResultCollector.error_logging">false</boolProp>
          <objProp>
            <name>saveConfig</name>
            <value class="SampleSaveConfiguration">
              <time>true</time>
              <latency>true</latency>
              <timestamp>true</timestamp>
              <success>true</success>
              <label>true</label>
              <code>true</code>
              <message>true</message>
              <threadName>true</threadName>
              <dataType>true</dataType>
              <encoding>false</encoding>
              <assertions>true</assertions>
              <subresults>true</subresults>
              <responseData>false</responseData>
              <samplerData>false</samplerData>
              <xml>false</xml>
              <fieldNames>true</fieldNames>
              <responseHeaders>false</responseHeaders>
              <requestHeaders>false</requestHeaders>
              <responseDataOnError>false</responseDataOnError>
              <saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
              <assertionsResultsToSave>0</assertionsResultsToSave>
              <bytes>true</bytes>
              <sentBytes>true</sentBytes>
              <url>true</url>
              <threadCounts>true</threadCounts>
              <idleTime>true</idleTime>
              <connectTime>true</connectTime>
            </value>
          </objProp>
          <stringProp name="filename"></stringProp>
        </ResultCollector>
        <hashTree/>
      </hashTree>
    </hashTree>
  </hashTree>
</jmeterTestPlan>

1 个答案:

答案 0 :(得分:0)

您的测试计划看起来不错,很可能您忘记了一个小步骤:​​您需要重新启动JMeter才能从其classpath 中拾取新的.jar。

如果您想在不重启JMeter的情况下快速测试.jar,则可以在Test Plan级添加

enter image description here

您可能还对Building a JMS Testing Plan - Apache JMeter指南感兴趣,该指南涵盖了JMeter official documentation on JMS testing的空白。