I am taking ExampleQueue as an example in HornetQ itself, by using JMeter sender to add load to the ExampleQueue, and write some code to create a dummy consumer listening to ExampleQueue to print out received text:
first you need to add .jar into jmeter\lib which you can get from HornetQ lib:
hornetq-core-client.jar
hornetq-jms-client.jar
hornetq-transports.jar
netty.jar
jnp-client.jar
jboss-jms-api.jar
Sender by Jmeter(click to see big pic):
看附件sender
Consumer by Jmeter(You need to come up with JMSCorrelationID in JMS header otherwise you may get an Error):
ERROR - jmeter.protocol.jms.sampler.FixedQueueExecutor: Correlation id is null. Set the JMSCorrelationID header
Here is my configuration(click to see big pic):
看附件p2p
multi-thread Sender by Java code sample:
package msq;
import java.util.Hashtable;
import javax.jms.JMSException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.NamingException;
import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
public class JMS_Q_Sender_threads {
static int TASK_NUM=10;
static class MyTask implements Runnable{
public void run(){
try{
// Step 1. Create an initial context to perform the JNDI lookup.
Hashtable env = new Hashtable();
env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
Context ctx = new InitialContext(env);
// Step 2. Lookup the connection factory
ConnectionFactory cf = (ConnectionFactory)ctx.lookup("/ConnectionFactory");
// Step 3. Lookup the JMS queue
Queue queue = (Queue)ctx.lookup("/queue/ExampleQueue");
// Step 4. Create the JMS objects to connect to the server and manage a session
Connection connection = cf.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
// Step 5. Create a JMS Message Producer to send a message on the queue
MessageProducer producer = session.createProducer(queue);
// Step 6. Create a Text Message and send it using the producer
final int numMessages = 5;
for (int i = 0; i < numMessages; i++){
TextMessage message = session.createTextMessage("Hello, HornetQ!");
producer.send(message);
System.out.println(Thread.currentThread().getId()+": Sent message: " + message.getText());
}
// Finally, we clean up all the JMS resources
connection.close();
} catch (Exception e){}
}
}
public static void main(final String[] args) throws NamingException, JMSException
{
MyTask task=new MyTask();
ExecutorService pool=Executors.newFixedThreadPool(5);
for (int i=0;i < TASK_NUM ; i++){
pool.submit(task);
}
pool.shutdown();
}
}
Consumer by Java code sample:
package msq;
import java.util.Hashtable;
import javax.jms.JMSException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.MessageConsumer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.NamingException;
public class JMS_Q_Consumer {
public static void main(final String[] args) throws NamingException, JMSException
{
// Step 1. Create an initial context to perform the JNDI lookup.
Hashtable env = new Hashtable();
env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
Context ctx = new InitialContext(env);
// Step 2. Lookup the connection factory
ConnectionFactory cf = (ConnectionFactory)ctx.lookup("/ConnectionFactory");
// Step 3. Lookup the JMS queue
Queue queue = (Queue)ctx.lookup("/queue/ExampleQueue");
// Step 4. Create the JMS objects to connect to the server and manage a session
Connection connection = cf.createConnection();
Session session2 = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer messageConsumer = session2.createConsumer(queue);
// Step 5. Start the Connection so that the server starts to deliver messages
connection.start();
int j = 0;
// final int num = 5;
// while(j <= num){
final long duration = 60000;
long start = System.currentTimeMillis();
while (System.currentTimeMillis() - start <= duration){
// Step 6. Receive the message
TextMessage messageReceived = (TextMessage)messageConsumer.receive(5000);
if (messageReceived != null) {
j++;
System.out.println(j + "Received message: " + messageReceived.getText());
}
else {
System.out.println("no message detected");
break ;
}
}
long end = System.currentTimeMillis();
double rate = 1000 * (double)j / (end - start);
System.out.println("We consumed " + j + " messages in " + (end - start) + " milliseconds");
System.out.println("Actual consume rate was " + rate + " messages per second");
// Finally, we clean up all the JMS resources
connection.close();
}
}
You can create any type of consumer based on your requirement and get the performance data accordingly.
And also I used Jconsole Mbeans to help monitoring the Queue JMS message at the mean time. So that we can notice if there is anything wrong with the Queue ASAP.
相关推荐
将 jpgc-graphs-basic-2.0.zip 解压缩后只有一个 lib 目录,该目录下有一个 ext 文件夹和一个 jmeter-plugins-cmn-jmeter-0.3.jar 包,ext 文件夹中有 jmeter-plugins-graphs-basic-2.0.jar 和 jmeter-plugins-...
Apache jmeter jmeter-plugins-cmn-jmeter-0.6.jar 下载
apache-jmeter-5.6.3.zip apache-jmeter-5.6.3.tgz apache-jmeter-5.6.3_src.zip apache-jmeter-5.6.3_src.tgz
https://blog.csdn.net/qq355667166/article/details/78914453),经过测试同学选型最终确认了采用jmeter+插件化jmeter-plugins-for-apache-dubbo(https://github.com/thubbo/jmeter-plugins-for-apache-dubbo)的...
4个jmeter测试报告模板集合 jmeter.results.shanhe.me.xsl jmeter.results.zyanycall.me.xsl jmeter-results-detail-report_30.xsl jmeter-results-report_21.xsl
jmeter-plugins-dubbo插件则允许开发者通过JMeter直接对Dubbo服务进行压力测试,模拟高并发请求,以验证服务在极限条件下的表现。 这个压缩包包含两个核心文件: 1. `jmeter-plugins-dubbo-2.7.1-jar-with-...
在本场景中,"apache-jmeter-rabbitMQ测试.zip" 提供了一个针对RabbitMQ的性能压力测试解决方案,特别适合测试其生产和消费性能。RabbitMQ是一个流行的开源消息代理,基于AMQP(Advanced Message Queuing Protocol)...
此外,“jmeter-plugins-manager-1.7.jar”还支持自定义插件仓库,这意味着团队或企业可以根据自身需求创建私有插件库,便于内部共享和管理特定的插件,保持团队测试环境的一致性。 总的来说,JMeter Plugins ...
本文将深入探讨“jmeter-plugins-redis2”这个插件,以及它如何助力于JMeter在接口测试中实现与Redis的数据交互。 首先,"jmeter-plugins-redis2"是一个专为JMeter设计的插件,它的核心功能在于实现了JMeter与Redis...
在本"apache-jmeter-5.0压力测试安装包"中,包含的是Apache JMeter 5.0版本,这是一个重要的里程碑,因为它引入了多项改进和新特性,旨在提升测试效率和准确性。 首先,让我们了解一下JMeter的核心概念。JMeter是...
jmeter-plugins-graphs-basic-2.0.jar是jmeter性能测试图形化显示插件
Apache JMeter (apache-jmeter-5.5.zip)可用于测试静态和动态资源、Web 动态应用程序的性能。 它可用于模拟服务器、服务器组、网络或对象上的重负载,以测试其强度或分析不同负载类型下的整体性能。 Apache JMeter...
总之,"apache-jmeter-5.2.tgz"是一个包含JMeter 5.2版本的Linux压力测试工具包,它能帮助测试团队在Linux环境中有效地进行性能测试,解决Windows端口回收慢的问题,以及进行大规模的分布式测试。掌握JMeter的使用,...
总结来说,"jmeter-plugins-extras-libs-1.1.3"和"jmeter-plugins-standard-1.1.3"是JMeter测试生态中的重要组成部分,它们通过扩展和强化JMeter的内置功能,帮助测试人员应对复杂的性能测试挑战。了解并熟练运用...
【JMeter】JMeter插件管理插件:jmeter-plugins-manager-1.3.jar Apache JMeter是一款开源的性能测试工具,广泛应用于Web应用、FTP服务器、数据库等服务的负载和压力测试。JMeter的强大之处在于其丰富的插件生态...
总结,`jmeter-plugins-manager-1.4.jar`插件是JMeter的强大辅助工具,通过它,用户可以轻松管理和利用各种插件,提升测试效率,实现更复杂、更贴近实际场景的性能测试。了解并熟练使用这个插件,对于任何JMeter使用...
jmeter的dubbo插件,jmeter-plugins-dubbo-2.7.8-jar-with-dependencies.jar,适用于JMeter5.4.1版本,将解压后的文件jmeter-plugins-dubbo-2.7.8-jar-with-dependencies放在Jmeter安装目录下的\lib\ext文件夹中,...
【标题】"jmeter-results-detail-report_21接口测试报告优化-展示具体的请求及返回值"涉及的关键知识点主要集中在接口测试、JMeter工具以及测试结果报告的详细展示上。接口测试是软件测试的重要组成部分,主要验证...
标题提到的两个压缩包文件分别是"apache-jmeter-3.0.zip"和"apache-jmeter-3.0_src.zip",它们代表了JMeter 3.0的不同版本。 1. **apache-jmeter-3.0.zip**:这是一个二进制发行版,包含了预编译的JMeter程序,用户...
标题 "jmeter-results-detail-report_30.rar" 暗示了这可能是一个使用Apache JMeter工具进行性能测试后的结果报告。JMeter是一款开源、Java编写的负载和性能测试工具,广泛应用于Web应用的压力测试。这个压缩包很...