[jboss-user] [Messaging, JMS & JBossMQ] - Problem shutting down persistant JMS queue.

Finix do-not-reply at jboss.com
Mon Apr 7 11:07:19 EDT 2008


Hi together, 

I have a problem with a persitant JMS queue (JBoss 4.2.2 with JBoss MQ). 
It seems that the queue is not waiting for the MDBs to return the onMessage() method to commit or rollback the transaction. After shutting down and restart of the queue, many messages are duplicated.

Is this a known bug or is something with my configuration not right.

Thanks and greets, Alex

A simple testcase which sends just incrementing Longs as messages and a MDB which just logs them out has this log:


  | WorkManager(2)-111 1777034 INFO  20080407 16:43:16,082 upload.TestQueueMDB [15] Got: 806
  | WorkManager(2)-122 1777081 INFO  20080407 16:43:16,129 upload.TestQueueMDB [15] Got: 807
  | WorkManager(2)-117 1777097 INFO  20080407 16:43:16,145 upload.TestQueueMDB [15] Got: 808
  | WorkManager(2)-115 1777144 INFO  20080407 16:43:16,192 upload.TestQueueMDB [15] Got: 809
  | WorkManager(2)-121 1777315 INFO  20080407 16:43:16,363 upload.TestQueueMDB [15] Got: 810
  | WorkManager(2)-125 1777331 INFO  20080407 16:43:16,379 upload.TestQueueMDB [15] Got: 811
  | WorkManager(2)-127 1777409 INFO  20080407 16:43:16,457 upload.TestQueueMDB [15] Got: 812
  | WorkManager(2)-120 1777425 INFO  20080407 16:43:16,473 upload.TestQueueMDB [15] Got: 813
  | WorkManager(2)-123 1777456 INFO  20080407 16:43:16,504 upload.TestQueueMDB [15] Got: 815
  | WorkManager(2)-109 1777456 INFO  20080407 16:43:16,504 upload.TestQueueMDB [15] Got: 814
  | WorkManager(2)-134 1777456 INFO  20080407 16:43:16,504 upload.TestQueueMDB [15] Got: 816
  | WorkManager(2)-128 1777472 INFO  20080407 16:43:16,520 upload.TestQueueMDB [15] Got: 817
  | ScannerThread 1777472 INFO  20080407 16:43:16,520 upload.TestQueueMDB [] destroying worker 13
  | ScannerThread 1777472 INFO  20080407 16:43:16,520 upload.TestQueueMDB [] destroying worker 4
  | ScannerThread 1777472 INFO  20080407 16:43:16,520 upload.TestQueueMDB [] destroying worker 3
  | ScannerThread 1777472 INFO  20080407 16:43:16,520 upload.TestQueueMDB [] destroying worker 15
  | ScannerThread 1777472 INFO  20080407 16:43:16,520 upload.TestQueueMDB [] destroying worker 10
  | ScannerThread 1777472 INFO  20080407 16:43:16,520 upload.TestQueueMDB [] destroying worker 14
  | ScannerThread 1777472 INFO  20080407 16:43:16,520 upload.TestQueueMDB [] destroying worker 7
  | ScannerThread 1777472 INFO  20080407 16:43:16,520 upload.TestQueueMDB [] destroying worker 6
  | ScannerThread 1777472 INFO  20080407 16:43:16,520 upload.TestQueueMDB [] destroying worker 12
  | ScannerThread 1777472 INFO  20080407 16:43:16,520 upload.TestQueueMDB [] destroying worker 1
  | ScannerThread 1777472 INFO  20080407 16:43:16,520 upload.TestQueueMDB [] destroying worker 11
  | ScannerThread 1777472 INFO  20080407 16:43:16,520 upload.TestQueueMDB [] destroying worker 5
  | ScannerThread 1777472 INFO  20080407 16:43:16,520 upload.TestQueueMDB [] destroying worker 8
  | ScannerThread 1777472 INFO  20080407 16:43:16,520 upload.TestQueueMDB [] destroying worker 9
  | ScannerThread 1777472 INFO  20080407 16:43:16,520 upload.TestQueueMDB [] destroying worker 2
  | WorkManager(2)-133 1810050 INFO  20080407 16:43:49,098 upload.TestQueueMDB [] Creating worker 1
  | WorkManager(2)-126 1810050 INFO  20080407 16:43:49,098 upload.TestQueueMDB [] Creating worker 2
  | WorkManager(2)-140 1810050 INFO  20080407 16:43:49,098 upload.TestQueueMDB [] Creating worker 3
  | WorkManager(2)-135 1810050 INFO  20080407 16:43:49,098 upload.TestQueueMDB [] Creating worker 4
  | WorkManager(2)-130 1810050 INFO  20080407 16:43:49,098 upload.TestQueueMDB [] Creating worker 5
  | WorkManager(2)-144 1810050 INFO  20080407 16:43:49,098 upload.TestQueueMDB [] Creating worker 6
  | WorkManager(2)-142 1810050 INFO  20080407 16:43:49,098 upload.TestQueueMDB [] Creating worker 7
  | WorkManager(2)-148 1810050 INFO  20080407 16:43:49,098 upload.TestQueueMDB [] Creating worker 8
  | WorkManager(2)-132 1810050 INFO  20080407 16:43:49,098 upload.TestQueueMDB [] Creating worker 9
  | WorkManager(2)-131 1810050 INFO  20080407 16:43:49,098 upload.TestQueueMDB [] Creating worker 10
  | WorkManager(2)-139 1810066 INFO  20080407 16:43:49,114 upload.TestQueueMDB [] Creating worker 11
  | WorkManager(2)-141 1810066 INFO  20080407 16:43:49,114 upload.TestQueueMDB [] Creating worker 12
  | WorkManager(2)-145 1810066 INFO  20080407 16:43:49,114 upload.TestQueueMDB [] Creating worker 13
  | WorkManager(2)-153 1810066 INFO  20080407 16:43:49,114 upload.TestQueueMDB [] Creating worker 14
  | WorkManager(2)-149 1810066 INFO  20080407 16:43:49,114 upload.TestQueueMDB [] Creating worker 15
  | WorkManager(2)-133 1810566 INFO  20080407 16:43:49,614 upload.TestQueueMDB [1] Got: 618
  | WorkManager(2)-130 1810566 INFO  20080407 16:43:49,614 upload.TestQueueMDB [5] Got: 623
  | WorkManager(2)-126 1810582 INFO  20080407 16:43:49,630 upload.TestQueueMDB [2] Got: 619
  | WorkManager(2)-153 1810582 INFO  20080407 16:43:49,630 upload.TestQueueMDB [14] Got: 633
  | WorkManager(2)-132 1810582 INFO  20080407 16:43:49,630 upload.TestQueueMDB [13] Got: 627
  | WorkManager(2)-131 1810582 INFO  20080407 16:43:49,630 upload.TestQueueMDB [13] Got: 620
  | WorkManager(2)-148 1810582 INFO  20080407 16:43:49,630 upload.TestQueueMDB [13] Got: 626
  | WorkManager(2)-141 1810582 INFO  20080407 16:43:49,630 upload.TestQueueMDB [13] Got: 629
  | WorkManager(2)-145 1810582 INFO  20080407 16:43:49,630 upload.TestQueueMDB [13] Got: 632
  | WorkManager(2)-140 1810582 INFO  20080407 16:43:49,630 upload.TestQueueMDB [3] Got: 622
  | 

MDB:

 /**
  |      * processes each message from jms queue.
  |      * @param pMessage the message
  |      */
  |     @TransactionAttribute(TransactionAttributeType.REQUIRED)
  |     public void onMessage(Message pMessage) {
  |         Long l = null;
  |         NDC.push(workerCount+"");
  |         try {
  |             Thread.sleep(500);
  |             l = (Long) ((ObjectMessage) pMessage).getObject();
  |         } catch (JMSException e) {
  |             LOG.error(e,e);
  |         } catch (InterruptedException e) {
  |             LOG.error(e,e);
  |         }
  | 
  |         LOG.info("Got: " + l);
  |         try {
  |             pMessage.acknowledge();
  |         } catch (JMSException e) {
  |            LOG.error(e);
  |         }
  |         NDC.pop();
  |     }

TestClient:

public void testDummyMessage() throws JMSException, NamingException {
  | 
  | 
  |        final TestJmsConHandler jmsCon = new TestJmsConHandler("/queue/testqueue");
  | 
  |         LOG.info("Sending message...");
  | 
  |         try {
  |             jmsCon.connect();
  |             LOG.info("JMS connected ... OK.");
  | 
  |             for ( int i = 0; i < 20000; i++) {
  |                 Long l = new Long(i);
  |                 final ObjectMessage m = jmsCon.getSession().createObjectMessage(l);
  |                 LOG.info("JMS Message " + i + " created  .... OK.");
  |                 jmsCon.send(m);//
  |             }
  | 
  |             LOG.info("JMS Message sent .... OK.");
  |         } finally {
  |             jmsCon.disconnect();
  |         }
  | 
  | 
  |     }

*-service.xml file:

<server>
  |     <mbean code="org.jboss.mq.server.jmx.Queue"
  |            name="jboss.mq.destination:service=Queue,name=testqueue">
  |         <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
  |         <!-- throw an excpetion when having more than this in the queue -->
  |         <attribute name="MaxDepth">1000000</attribute>
  |         <!-- Try to redliver a message when onMessage threw a runtime exeptiuon -->
  |         <attribute name="RedeliveryLimit">10</attribute>
  |         <!-- retry the delivery after 10 seconds -->
  |         <attribute name="RedeliveryDelay">10000</attribute>
  |         <!--<attribute name="MaximumSize">20</attribute>-->
  |     </mbean>
  | 
  | </server>

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4142102#4142102

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4142102



More information about the jboss-user mailing list