我有两个程序,第一个是制作人:
public class Producer {
public static void main(String[] args) throws Exception {
final ConnectionFactory cf = new ActiveMQConnectionFactory("tcp://localhost:12345");
final Connection c = cf.createConnection();
final Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
final TextMessage msg = s.createTextMessage("rho " + new Date().toString());
final MessageProducer p = s.createProducer(new ActiveMQQueue("rmannibucau"));
p.send(msg);
p.close();
s.close();
c.close();
}
}
第二个是消费者:
public class Listener {
public static void main(String[] args) throws Exception {
final ConnectionFactory cf = new ActiveMQConnectionFactory("tcp://localhost:12345");
final Connection c = cf.createConnection();
final Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
s.createConsumer(s.createQueue("rmannibucau")).setMessageListener(new MessageListener() {
@Override
public void onMessage(Message message) {
System.out.println(message.toString());
}
});
c.start();
s.run();
}
}
我使用 ActiveMQ、java、jms,我想用 Jmetter 进行测试,以了解消费者在 1 分钟内可以消耗多少消息,请帮助我。