FileDocCategorySizeDatePackage
GenericDLQHandler.javaAPI DocJBoss 4.2.13765Fri Jul 13 21:01:16 BST 2007org.jboss.resource.adapter.jms.inflow.dlq

GenericDLQHandler

public class GenericDLQHandler extends JBossMQDLQHandler
A Generic DLQ Handler
author
Adrian Brock
version
$Revision: 57189 $

Fields Summary
protected HashMap
resent
Resent messages Map
Constructors Summary
Methods Summary
protected voidclearResentCounter(java.lang.String id)
Remove the resent counter for the message id

param
id the message id of the message

      synchronized (resent)
      {
         resent.remove(id);
      }
   
protected booleanhandleDelivery(javax.jms.Message msg)

      // Check for JBossMQ specific
      boolean handled = super.handleDelivery(msg);
      if (handled)
         return true;
      
      try
      {
         if (msg.propertyExists(JMS_JBOSS_REDELIVERY_COUNT))
            return false;

         String id = msg.getJMSMessageID();
         if (id == null)
         {
            log.error("Message id is null? " + msg);
            return false;
         }

         int count = 0;
         
         try
         {
            if (msg.propertyExists(PROPERTY_DELIVERY_COUNT))
               count = msg.getIntProperty(PROPERTY_DELIVERY_COUNT) - 1;
         }
         catch (JMSException ignored)
         {
            count = incrementResentCounter(id);
         }
         
         if (count > maxResent)
         {
            warnDLQ(msg, count, maxResent);
            clearResentCounter(id);
            return true;
         }
      }
      catch (Throwable t)
      {
         log.warn("Unexpected error checking whether dlq should be used " + msg, t);
      }
      
      return false;
   
protected intincrementResentCounter(java.lang.String id)
Increment the resent counter for the message id

param
id the message id of the message

      ResentInfo info;
      synchronized (resent)
      {
         info = (ResentInfo) resent.get(id);
         if (info == null)
         {
            info = new ResentInfo();
            resent.put(id, info);
         }
      }
      return ++info.count;
   
public voidmessageDelivered(javax.jms.Message msg)


      
   
      try
      {
         String id = msg.getJMSMessageID();
         if (id == null)
         {
            log.error("Message id is null? " + msg);
            return;
         }

         clearResentCounter(id);
      }
      catch (Throwable t)
      {
         log.warn("Unexpected error processing delivery notification " + msg, t);
      }