JMS性能 [英] JMS performance
本文介绍了JMS性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从性能角度理解JMS我遇到了一些麻烦。我们在我们的应用程序中有这个非常简单的代码:
I'm having a bit of trouble with understanding JMS from a performance perspective. We have this very straightforward code in our application:
QueueConnection connection = null;
QueueSession session = null;
QueueSender sender = null;
TextMessage msg = null;
try {
// The JNDIHelper uses InitialContext to look up things
QueueConnectionFactory qcf = JNDIHelper.lookupFactory();
Queue destQueue = JNDIHelper.lookupQueue();
// These objects are created for every message, which is quite slow
connection = qcf.createQueueConnection();
session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
sender = session.createSender(destQueue);
// This is the actual message
msg = session.createTextMessage(xmlMsg);
sender.setTimeToLive(0);
sender.send(msg);
}
finally {
// Close all objects again
JMSUtilities.safeClose(sender);
JMSUtilities.safeClose(session);
JMSUtilities.safeClose(connection);
}
代码是正确的,但可能上面的一些人工制品可以重复使用几条消息。这些是我们的配置:
The code is correct, but probably some of the above artefacts could be reused for several messages. These are our configurations:
- 我们使用Oracle Weblogic 10.3.3
- Weblogic连接到IBM MQ用于JMS的7.0(6.0中也出现问题)
- 上述逻辑由后端服务器上的单个线程执行。保留一些对象很简单(
QueueConnection
,QueueSession
,QueueSender
)在内存中,因为没有涉及并发。
- We use Oracle Weblogic 10.3.3
- Weblogic connects to IBM MQ 7.0 (Problem also appears with 6.0) for JMS
- The above logic is executed by a single thread on a backend server. It would be simple to keep some objects (
QueueConnection
,QueueSession
,QueueSender
) in memory as there is no concurrency involved.
- 哪些类型的对象可以在多条消息之间共享? (当然我们会包含错误恢复,还原那些共享对象)
- 提高性能的最佳做法是什么?
推荐答案
您需要一次又一次创建的是 msg
本身 - 如果您要发送给相同的队列。
The only thing you need to create again and again is the msg
itself - if you are sending to the same queue.
所以是的,你可以记住连接,会话和发件人。
So yes, you can remember the Connection, Session and Sender.
这篇关于JMS性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文