Message Driven Bean is not responding
rocky.alam May 11, 2006 3:19 PMhi,
I am using a message driven bean deployed in JBoss 4.0.2 to listen to a queue in WebSphere MQ 5.3. Randomly after processing about couple of thousand messages (sometimes hundreds) it stops responding and no further messages are picked up from the queue.
Here is the mdb code:
public void onMessage (Message message) { try{ if (message instanceof TextMessage) { //Initialize the handler VOTSMessageHandler handler = new VOTSMessageHandler(); //Cast message to JMS TextMessage TextMessage msg = (TextMessage)message; //Extract message from the JMS TextMessage into a stringbuffer StringBuffer text = new StringBuffer(msg.getText()); //Extract the message type from the message body (VOTS--> first 6 characters) String msgType = text.substring(0,6); //Log the receipt of the message for debugging CmsLog.getMessageLog().info("Message received with message ID "+ msgType+ " containing : "+ msg.getText()); //invoke the handler method for further processing handler.getParsedMessage(text.toString(),msgType); } } catch(Exception e){ //Rollback when any exception is thrown this.context.setRollbackOnly(); //Log the exception for debugging CmsLog.getProcessLog().error("VOTS Message Processing Failed : "); } }
jboss.xml
<jboss> <enterprise-beans> <message-driven> <ejb-name>VOTSMessageBean</ejb-name> <destination-jndi-name>HCPDCMS/FROM.VOTS</destination-jndi-name> <configuration-name>Singleton Message Driven Bean</configuration-name> <resource-ref> <res-ref-name>HCPDCMS/FROM.VOTS</res-ref-name> <jndi-name>HCPDCMS/MQ_HCPDCMS_QCF</jndi-name> </resource-ref> </message-driven> </enterprise-beans> </jboss>
ejb-jar.xml
<ejb-jar> <enterprise-beans> <message-driven> <ejb-name>VOTSMessageBean</ejb-name> <ejb-class>com.vai.cms.ejb.message.vots.VOTSMessageBean</ejb-class> <transaction-type>Container</transaction-type> <acknowledge-mode>Auto-acknowledge</acknowledge-mode> <message-driven-destination> <destination-type>javax.jms.Queue</destination-type> </message-driven-destination> <resource-ref> <res-ref-name>HCPDCMS/FROM.VOTS</res-ref-name> <res-type>com.vai.cms.jmx.wsmq.WSMQConnectionFactory</res-type> <res-auth>Container</res-auth> </resource-ref> </message-driven> </enterprise-beans> <assembly-descriptor> <container-transaction> <method> <ejb-name>VOTSMessageBean</ejb-name> <method-name>onMessage</method-name> <method-params> <method-param>javax.jms.Message</method-param> </method-params> </method> <trans-attribute>RequiresNew</trans-attribute> </container-transaction> </assembly-descriptor> </ejb-jar>
After analyzing the thread dump, I see a deadlock that I cannot understand. Here is the thread:
"MQQueueAgent (FROM.VOTS)" daemon prio=5 tid=0x47c30230 nid=0x240c in Object.wait() [0x4d04f000..0x4d04fbec] at java.lang.Object.wait(Native Method) - waiting on <0x0acbcea0> (a java.util.ArrayList) at java.lang.Object.wait(Object.java:474) at org.jboss.jms.asf.StdServerSessionPool.getServerSession(StdServerSessionPool.java:206) - locked <0x0acbcea0> (a java.util.ArrayList) at com.ibm.mq.jms.MQConnectionConsumer.deliverNow(MQConnectionConsumer.java:592) at com.ibm.mq.jms.MQConnectionConsumer.deliver(MQConnectionConsumer.java:554) at com.ibm.mq.jms.MQQueueAgent.deliver(MQQueueAgent.java:723) - locked <0x0acbcf40> (a java.util.Vector) at com.ibm.mq.jms.MQQueueAgentThread.processMessage(MQQueueAgentThread.java:763) at com.ibm.mq.jms.MQQueueAgentThread.run(MQQueueAgentThread.java:933) at java.lang.Thread.run(Thread.java:595)
It is obviously waiting on the same object that it locked (in bold). Does anybody have any idea how to fix this?
Any pointer will be appreicated!
Thanks.