将多条消息插入到 Websphere MQ 的速度非常慢
出于测试目的,我想生成大约一百万条消息到 MQ。但是在 200-300 条消息之后插入变得非常慢,100 条消息插入需要近 30 秒。在 3700 条消息之后,我收到了 MQException(原因 2010)。
我在 groovy 中的代码
import com.ibm.mq.*
MQEnvironment.@hostname = "srv-cci2"
MQEnvironment.@port = 1414
MQEnvironment.@channel = "SYSTEM.ADMIN.SVRCONN"
MQEnvironment.disableTracing();
MQException.log = null;
def queueManager = new MQQueueManager("QM_srv_cci2")
int putOpenOpts = MQC.MQOO_OUTPUT | MQC.MQOO_FAIL_IF_QUIESCING;
def putMsg = new MQMessage();
putMsg.setVersion(MQC.MQMD_VERSION_2);
putMsg.format = MQC.MQFMT_STRING;
putMsg.characterSet = 1250;
def xml = """<?xml version="1.0" encoding="windows-1250"?>
"""
for (int i = 1; i < 1000000; i++) {
def putQ = queueManager.accessQueue("SOA_EVENT.IN", putOpenOpts);
putMsg.writeString(xml);
def pmo = new MQPutMessageOptions();
putQ.put(putMsg, pmo);
putQ.close()
if (i % 100 == 0) {
println ("" + new Date() + " " + i)
}
}
queueManager.disconnect()
所以主要问题 - 这可能吗 - 快速插入 100 万条消息到 Webspere MQ?以及如何做到这一点?
For testing purpose I want to generate about one million messages to MQ. But after 200-300 messages inserting becomes very slow, near 30 seconds for 100 messages. And after 3700 messages I have got MQException (Reason 2010).
My code in groovy
import com.ibm.mq.*
MQEnvironment.@hostname = "srv-cci2"
MQEnvironment.@port = 1414
MQEnvironment.@channel = "SYSTEM.ADMIN.SVRCONN"
MQEnvironment.disableTracing();
MQException.log = null;
def queueManager = new MQQueueManager("QM_srv_cci2")
int putOpenOpts = MQC.MQOO_OUTPUT | MQC.MQOO_FAIL_IF_QUIESCING;
def putMsg = new MQMessage();
putMsg.setVersion(MQC.MQMD_VERSION_2);
putMsg.format = MQC.MQFMT_STRING;
putMsg.characterSet = 1250;
def xml = """<?xml version="1.0" encoding="windows-1250"?>
"""
for (int i = 1; i < 1000000; i++) {
def putQ = queueManager.accessQueue("SOA_EVENT.IN", putOpenOpts);
putMsg.writeString(xml);
def pmo = new MQPutMessageOptions();
putQ.put(putMsg, pmo);
putQ.close()
if (i % 100 == 0) {
println ("" + new Date() + " " + i)
}
}
queueManager.disconnect()
So main question - do this possible - quickly insert 1 million messages to Webspere MQ? And how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
2010 原因代码在以下常量名称中定义: MQRC_DATA_LENGTH_ERROR
在您调用的每次迭代中:
但它永远不会重置。在我看来,您不断向消息添加更多内容并发布它(每条消息都比前一条消息大)。
The 2010 reason code is defined in the following constant name: MQRC_DATA_LENGTH_ERROR
In each itereation you call:
But it is never reset. Looks to me that you keep adding more content to the message and posting it (each message is larger than the previous one).