我目前正在使用 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 循环中按顺序遍历每条记录,从遗留表中获取相应的记录,比较字段值,必要时更新记录并在其他表中添加相应的新记录。
但是,我希望通过异步处理所有记录来提高性能。为此,我正在考虑将每个记录信息作为单独的消息发送,因此需要这么多消息。