2015年12月8日 | Leave a comment 问题: Caused by: com.sun.messaging.jms.MQRuntimeException: MQJMSRA_DS4001: JMSServiceException on send message:sendMessage: Sending message failed. Connection ID: 514344369131286016 Caused by:com.sun.messaging.jmq.jmsserver.util.BrokerException: [B4403]: Exception on processing produced message PacketReference[4004-192.168.31.232(f8:1c:d9:24:de:b9)-1-1449460088813][TID=514344369256300544, null]: [B4303]: The maximum number of messages [1,000] that the producer can process in a single transaction (TID=514344369256300544) has been exceeded. Please either limit the # of messages per transaction or increase the imq.transaction.producer.maxNumMsgs property. 解决: 原来使用的是JMSContext ,改为使用 connectionFactory 创建不带transaction的session try (Connection conn = connectionFactory.createConnection()) { for(int i=0;i<10000;++i){ try (Session session = conn.createSession(Session.AUTO_ACKNOWLEDGE) //不使用jmscontext 是为了避免transaction ) { MessageProducer producer= session.createProducer(crm_activity_queue); ObjectMessage msg=session.createObjectMessage(act2); producer.send(msg); } } } 12345678910 try (Connection conn = connectionFactory.createConnection()) {for(int i=0;i<10000;++i){try (Session session = conn.createSession(Session.AUTO_ACKNOWLEDGE) //不使用jmscontext 是为了避免transaction ) { MessageProducer producer= session.createProducer(crm_activity_queue); ObjectMessage msg=session.createObjectMessage(act2); producer.send(msg); }}} JMSContext 在ejb中是transaction 的,所以循环中一万条消息都在一个事务中,我们的业务场景是没必要使用transaction的