2 Replies Latest reply on Mar 13, 2013 11:59 AM by ansur

    Reprocess DLQ

    ansur

      There have been some topics on removing messages from DLQ - which doesn't seem like something easy to accomplish with JMS.

       

      The requirement that I have is that we need to enable users to reprocess a DLQ.

      My current implementation boils down to the following snippet:

       

                      final QueueBrowser browser = session.createBrowser(queue);
                      final Enumeration<Message> jmsMessages = browser.getEnumeration();
                      
                      while(jmsMessages.hasMoreElements()) {
                          final Message jmsMessage = jmsMessages.nextElement();
                          final Destination destination = jmsMessage.getJMSDestination();
                          
                          sendMessage(jmsMessage, destination, session);
                      }
      

       

      I.e. create a browser, and for each message, get the destination and send it there. the sendMessage() method creates a MessageProducer and calls the send() method.

       

      This is working fine, but the message isn't actually removed from the DLQ.

      What behaviour would I need in order to have it removed after processing?

       

      After all, if the message fails to process again, it would just en dup in the DLQ again - which is OK.

       

      Finally, the above is part of a manual action. So I can't just register an MDB on the DLQ - it needs to be a manual invocation.