[jmeter]-hornetq测试

简介:

I figured out the problem, for the benefits of others.

1. These are the jars needed in jmeter/lib : netty.jar,jboss-jms-api.jar,netty.jar,jnp-client.jar,hornetq-transports.jar,hornetq-jms-client.jar,hornetq-core-client.jar

2. use the connection factory name : ConnectionFactory which is defeined in hornetq configuration

3. define your jms topic used in jmeter in hornetq-jms.xml

 

 

 

Sunday, April 11, 2010

HornetQ JMS Queue testing using Sender and Consumer

Here is a dummy demo of how to test JMS performance by JMeter sender(Point-to-Point) and Consumer.  
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.
目录
相关文章
|
4月前
|
测试技术 持续交付 Apache
Python性能测试新风尚:JMeter遇上Locust,性能分析不再难🧐
【10月更文挑战第1天】Python性能测试新风尚:JMeter遇上Locust,性能分析不再难🧐
218 3
|
1月前
|
缓存 网络协议
Jmeter如何对UDP协议进行测试?
`jmeter-plugins`是JMeter的插件管理器,用于管理和组织所有插件。访问[官网](https://jmeter-plugins.org/install/Install/)下载并放置于`lib/ext`目录下,重启JMeter后可在“选项”中看到插件管理器。
30 1
Jmeter如何对UDP协议进行测试?
|
5月前
|
测试技术 数据库 UED
Python 性能测试进阶之路:JMeter 与 Locust 的强强联合,解锁性能极限
【9月更文挑战第9天】在数字化时代,确保软件系统在高并发场景下的稳定性至关重要。Python 为此提供了丰富的性能测试工具,如 JMeter 和 Locust。JMeter 可模拟复杂请求场景,而 Locust 则能更灵活地模拟真实用户行为。结合两者优势,可全面评估系统性能并优化瓶颈。例如,在电商网站促销期间,通过 JMeter 模拟大量登录请求并用 Locust 模拟用户浏览和购物行为,可有效识别并解决性能问题,从而提升系统稳定性和用户体验。这种组合为性能测试开辟了新道路,助力应对复杂挑战。
166 2
|
3月前
|
测试技术 持续交付 Apache
Python性能测试新风尚:JMeter遇上Locust,性能分析不再难🧐
Python性能测试新风尚:JMeter遇上Locust,性能分析不再难🧐
188 3
|
3月前
|
缓存 测试技术 Apache
告别卡顿!Python性能测试实战教程,JMeter&Locust带你秒懂性能优化💡
告别卡顿!Python性能测试实战教程,JMeter&Locust带你秒懂性能优化💡
101 1
|
5月前
|
缓存 Java 测试技术
谷粒商城笔记+踩坑(11)——性能压测和调优,JMeter压力测试+jvisualvm监控性能+资源动静分离+修改堆内存
使用JMeter对项目各个接口进行压力测试,并对前端进行动静分离优化,优化三级分类查询接口的性能
172 10
谷粒商城笔记+踩坑(11)——性能压测和调优,JMeter压力测试+jvisualvm监控性能+资源动静分离+修改堆内存
|
5月前
|
移动开发 JSON Java
Jmeter实现WebSocket协议的接口测试方法
WebSocket协议是HTML5的一种新协议,实现了浏览器与服务器之间的全双工通信。通过简单的握手动作,双方可直接传输数据。其优势包括极小的头部开销和服务器推送功能。使用JMeter进行WebSocket接口和性能测试时,需安装特定插件并配置相关参数,如服务器地址、端口号等,还可通过CSV文件实现参数化,以满足不同测试需求。
326 7
Jmeter实现WebSocket协议的接口测试方法
|
4月前
|
缓存 测试技术 Apache
告别卡顿!Python性能测试实战教程,JMeter&Locust带你秒懂性能优化💡
【10月更文挑战第1天】告别卡顿!Python性能测试实战教程,JMeter&Locust带你秒懂性能优化💡
123 4
|
5月前
|
测试技术 持续交付 Apache
Python性能测试新风尚:JMeter遇上Locust,性能分析不再难🧐
【9月更文挑战第10天】随着软件应用的不断扩展,性能测试成为确保系统稳定运行的关键环节。本文通过对比Apache JMeter和Locust,探讨了如何在Python环境中利用这两款工具挖掘更多性能测试潜力。JMeter是一款成熟且功能强大的开源工具,支持多种协议,适用于各种应用的测试;而Locust则基于Python,通过简单脚本模拟HTTP请求,更适合Web应用测试。
140 3
|
5月前
|
消息中间件 监控 测试技术
惊呆了!Python性能测试高手都用这些神器:JMeter+Locust,效率翻倍📈
【9月更文挑战第8天】在软件开发中,性能测试对确保应用稳定性和高效运行至关重要。对于Python开发者而言,选择合适的性能测试工具能显著提升测试效率并精准定位性能瓶颈。本文深入探讨了JMeter和Locust这两款工具的独特优势。JMeter作为跨平台的性能测试工具,支持多种协议,具备高度可定制性和扩展性;而Locust则专为Python应用设计,利用协程实现高并发,提供实时监控和分布式测试功能。两者结合使用,可在实际项目中实现1+1&gt;2的效果,帮助开发者构建全面高效的测试方案,保障应用稳定运行。
304 1

热门文章

最新文章

  • 1
    小鱼深度评测 | 通义灵码2.0,不仅可跨语言编码,自动生成单元测试,更炸裂的是集成DeepSeek模型且免费使用,太炸裂了。
  • 2
    3天功能开发→3小时:通义灵码2.0+DEEPSEEK实测报告,单元测试生成准确率92%的秘密
  • 3
    Potpie.ai:比Copilot更狠!这个AI直接接管项目代码,自动Debug+测试+开发全搞定
  • 4
    基于FPGA的图像双线性插值算法verilog实现,包括tb测试文件和MATLAB辅助验证
  • 5
    【01】噩梦终结flutter配安卓android鸿蒙harmonyOS 以及next调试环境配鸿蒙和ios真机调试环境-flutter项目安卓环境配置-gradle-agp-ndkVersion模拟器运行真机测试环境-本地环境搭建-如何快速搭建android本地运行环境-优雅草卓伊凡-很多人在这步就被难倒了
  • 6
    大前端之前端开发接口测试工具postman的使用方法-简单get接口请求测试的使用方法-简单教学一看就会-以实际例子来说明-优雅草卓伊凡
  • 7
    「ximagine」业余爱好者的非专业显示器测试流程规范,同时也是本账号输出内容的数据来源!如何测试显示器?荒岛整理总结出多种测试方法和注意事项,以及粗浅的原理解析!
  • 8
    以项目登录接口为例-大前端之开发postman请求接口带token的请求测试-前端开发必学之一-如果要学会联调接口而不是纯写静态前端页面-这个是必学-本文以优雅草蜻蜓Q系统API为实践来演示我们如何带token请求接口-优雅草卓伊凡
  • 9
    AxBench:斯坦福大学推出评估语言模型控制方法的基准测试框架
  • 10
    Burp Suite Professional 2025.2 (macOS, Linux, Windows) - Web 应用安全、测试和扫描