OpenMQ 中发送到队列的最大消息数?

发布于 2024-08-11 08:13:38 字数 2665 浏览 2 评论 0原文

我目前正在使用 Glassfish v2.1,并且已经设置了一个队列来分别使用会话 bean 和 MDB 发送和接收消息。但是,我注意到最多只能向队列发送 1000 条消息。有什么原因导致我无法向队列发送超过 1000 条消息吗?我确实有 glassfish 域的“开发人员”配置文件设置。难道是这个原因吗?或者是否有一些我需要修改的资源配置设置?

我已经设置了 sun-resources.xml 配置属性,如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Resource Definitions //EN" "http://www.sun.com/software/appserver/dtds/sun-resources_1_3.dtd">
<resources>
  <admin-object-resource
        enabled="true"
        jndi-name="jms/UpdateQueue"
        object-type="user"
        res-adapter="jmsra"
        res-type="javax.jms.Queue">
    <description/>
    <property name="Name" value="UpdatePhysicalQueue"/>
  </admin-object-resource>
  <connector-resource
        enabled="true" jndi-name="jms/UpdateQueueFactory"
        object-type="user"
        pool-name="jms/UpdateQueueFactoryPool">
    <description/>
  </connector-resource>
  <connector-connection-pool
        associate-with-thread="false"
        connection-creation-retry-attempts="0"
        connection-creation-retry-interval-in-seconds="10"
        connection-definition-name="javax.jms.QueueConnectionFactory"
        connection-leak-reclaim="false"
        connection-leak-timeout-in-seconds="0"
        fail-all-connections="false"
        idle-timeout-in-seconds="300"
        is-connection-validation-required="false"
        lazy-connection-association="false"
        lazy-connection-enlistment="false"
        match-connections="true"
        max-connection-usage-count="0"
        max-pool-size="32"
        max-wait-time-in-millis="60000"
        name="jms/UpdateFactoryPool"
        pool-resize-quantity="2"
        resource-adapter-name="jmsra"
        steady-pool-size="8"
        validate-atmost-once-period-in-seconds="0"/>
</resources>

嗯..进一步调查在 imq 日志中显示了以下内容:

   [17/Nov/2009:10:27:57 CST] ERROR sendMessage: Sending message failed. Connection ID: 427038234214377984:
    com.sun.messaging.jmq.jmsserver.util.BrokerException: transaction failed: [B4303]: The maximum number of messages [1,000] that the producer can process in a single transaction (TID=427038234364096768) has been exceeded. Please either limit the # of messages per transaction or increase the imq.transaction.producer.maxNumMsgs property.

那么,如果我需要一次发送超过 5000 条消息,我该怎么办?

我想做的是读取表中的所有记录,并根据我只有只读访问权限的旧表中该记录的相应值来更新每个记录的特定字段。该表有超过 10k 条记录。截至目前,我正在 for 循环中顺序遍历每条记录,从旧表中获取相应的记录,比较字段值,如有必要更新记录,并在其他表中添加相应的新记录。

但是,我希望通过异步处理所有记录来提高性能。为此,我正在考虑将每个记录信息作为单独的消息发送,因此需要如此多的消息。

I am currently using Glassfish v2.1 and I have set up a queue to send and receive messages from with Sesion beans and MDBs respectively. However, I have noticed that I can send only a maximum of 1000 messages to the queue. Is there any reason why I cannot send more than 1000 messages to the queue? I do have a "developer" profile setup for the glassfish domain. Could that be the reason? Or is there some resource configuration setting that I need to modify?

I have setup the sun-resources.xml configuration properties as follows:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Resource Definitions //EN" "http://www.sun.com/software/appserver/dtds/sun-resources_1_3.dtd">
<resources>
  <admin-object-resource
        enabled="true"
        jndi-name="jms/UpdateQueue"
        object-type="user"
        res-adapter="jmsra"
        res-type="javax.jms.Queue">
    <description/>
    <property name="Name" value="UpdatePhysicalQueue"/>
  </admin-object-resource>
  <connector-resource
        enabled="true" jndi-name="jms/UpdateQueueFactory"
        object-type="user"
        pool-name="jms/UpdateQueueFactoryPool">
    <description/>
  </connector-resource>
  <connector-connection-pool
        associate-with-thread="false"
        connection-creation-retry-attempts="0"
        connection-creation-retry-interval-in-seconds="10"
        connection-definition-name="javax.jms.QueueConnectionFactory"
        connection-leak-reclaim="false"
        connection-leak-timeout-in-seconds="0"
        fail-all-connections="false"
        idle-timeout-in-seconds="300"
        is-connection-validation-required="false"
        lazy-connection-association="false"
        lazy-connection-enlistment="false"
        match-connections="true"
        max-connection-usage-count="0"
        max-pool-size="32"
        max-wait-time-in-millis="60000"
        name="jms/UpdateFactoryPool"
        pool-resize-quantity="2"
        resource-adapter-name="jmsra"
        steady-pool-size="8"
        validate-atmost-once-period-in-seconds="0"/>
</resources>

Hmm .. further investigation revealed the following in the imq logs:

   [17/Nov/2009:10:27:57 CST] ERROR sendMessage: Sending message failed. Connection ID: 427038234214377984:
    com.sun.messaging.jmq.jmsserver.util.BrokerException: transaction failed: [B4303]: The maximum number of messages [1,000] that the producer can process in a single transaction (TID=427038234364096768) has been exceeded. Please either limit the # of messages per transaction or increase the imq.transaction.producer.maxNumMsgs property.

So what would I do if I needed to send more than 5000 messages at a time?

What I am trying to do is to read all the records in a table and update a particular field of each record based on the corresponding value of that record in a legacy table to which I have only read only access. This table has more than 10k records in it. As of now, I am sequentially going through each record in a for loop, getting the corresponding record from the legacy table, comparing the field values, updating the record if necessary and adding corresponding new records in other tables.

However, I was hoping to improve performance by processing all the records asynchronously. To do that I was thinking of sending each record info as a separate message and hence requiring so many messages.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

辞旧 2024-08-18 08:13:38

要配置 OpenMQ 并设置 artitrary 代理属性,请查看此 博客文章

但实际上,我不建议增加 imq.transaction. Producer.maxNumMsgs 属性,至少不要高于 文档

生产者在单个事务中可以处理的最大消息数。建议该值小于5000,防止资源耗尽。

如果您需要发送更多消息,请考虑在多个事务中进行。

To configure OpenMQ and set artitrary broker properties, have a look at this blog post.

But actually, I wouldn't advice to increase the imq.transaction.producer.maxNumMsgs property, at least not above the value recommended in the documentation:

The maximum number of messages that a producer can process in a single transaction. It is recommended that the value be less than 5000 to prevent the exhausting of resources.

If you need to send more messages, consider doing it in several transactions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文