2个月前 (05-08) 铁匠  java
文章评分 0 次,平均分 0.0

activeMQ 如何调优

  1. 使用非持久化消息;
  2. 需要确保消息发送成功时使用事务来将消息分批组合
public void sendTransacted() throws JMSException {
ActiveMQConnectionFactory cf = new
ActiveMQConnectionFactory();
Connection connection = cf.createConnection();
connection.start();
Session session = connection.createSession(true,
Session.SESSION_TRANSACTED);
Topic topic = session.createTopic("Test.Transactions");
MessageProducer producer = session.createProducer(topic);
int count = 0;
for (int i = 0; i < 1000; i++) {
Message message = session.createTextMessage("message " +
i);
producer.send(message);
if (i != 0 && i % 10 == 0) {
	session.commit();
} } }
public void sendNonTransacted() throws JMSException {
ActiveMQConnectionFactory cf = new
ActiveMQConnectionFactory();
Connection connection = cf.createConnection();
connection.start();
// create a default session (no transactions)
Session session = connection.createSession(false,
Session.AUTO_ACKNOWELDGE);
Topic topic = session.createTopic("Test.Transactions");
MessageProducer producer = session.createProducer(topic);
int count = 0;
for (int i = 0; i < 1000; i++) {
Message message = session.createTextMessage("message " +
i);
producer.send(message);
} }




//下面这个css和插件后台设置的主题有关系,如果需要换样式,则需要修改以下CSS名称

1 2 3 4 5 6 7 8 9 10 11 12 13 14
 

除特别注明外,本站所有文章均为铁匠运维网原创,转载请注明出处来自http://www.tiejiang.org/26671.html

关于

发表评论

暂无评论

切换注册

登录

忘记密码 ?

切换登录

注册

扫一扫二维码分享