activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r569270 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
Date Fri, 24 Aug 2007 06:29:18 GMT
Author: rajdavies
Date: Thu Aug 23 23:29:18 2007
New Revision: 569270

URL: http://svn.apache.org/viewvc?rev=569270&view=rev
Log:
ensure exception is logged if one is raised sending a message to a dead letter queue

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java?rev=569270&r1=569269&r2=569270&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/RegionBroker.java
Thu Aug 23 23:29:18 2007
@@ -636,38 +636,48 @@
         getRoot().sendToDeadLetterQueue(context, node);
     }
 
-    public void sendToDeadLetterQueue(ConnectionContext context, MessageReference node) {
-        try {
-            if (node != null) {
-                Message message = node.getMessage();
-                if (message != null) {
-                    DeadLetterStrategy deadLetterStrategy = node.getRegionDestination().getDeadLetterStrategy();
-                    if (deadLetterStrategy != null) {
-                        if (deadLetterStrategy.isSendToDeadLetterQueue(message)) {
-                            long expiration = message.getExpiration();
-                            message.setExpiration(0);
-                            message.setProperty("originalExpiration", new Long(expiration));
-                            if (!message.isPersistent()) {
-                                message.setPersistent(true);
-                                message.setProperty("originalDeliveryMode", "NON_PERSISTENT");
-                            }
-                            // The original destination and transaction id do
-                            // not get filled when the message is first
-                            // sent,
-                            // it is only populated if the message is routed to
-                            // another destination like the DLQ
-                            ActiveMQDestination deadLetterDestination = deadLetterStrategy.getDeadLetterQueueFor(message.getDestination());
-                            BrokerSupport.resend(context, message, deadLetterDestination);
-                        }
-                    }
-                } else {
-                    LOG.warn("Null message for node: " + node);
-                }
-            }
-        } catch (Exception e) {
-            LOG.warn("Failed to pass expired message to dead letter queue");
-        }
-    }
+    public void sendToDeadLetterQueue(ConnectionContext context,
+	        MessageReference node){
+		try{
+			boolean sent=false;
+			if(node!=null){
+				Message message=node.getMessage();
+				if(message!=null&&node.getRegionDestination()!=null){
+					DeadLetterStrategy deadLetterStrategy=node
+					        .getRegionDestination().getDeadLetterStrategy();
+					if(deadLetterStrategy!=null){
+						if(deadLetterStrategy.isSendToDeadLetterQueue(message)){
+							long expiration=message.getExpiration();
+							message.setExpiration(0);
+							message.setProperty("originalExpiration",new Long(
+							        expiration));
+							if(!message.isPersistent()){
+								message.setPersistent(true);
+								message.setProperty("originalDeliveryMode",
+								        "NON_PERSISTENT");
+							}
+							// The original destination and transaction id do
+							// not get filled when the message is first
+							// sent,
+							// it is only populated if the message is routed to
+							// another destination like the DLQ
+							ActiveMQDestination deadLetterDestination=deadLetterStrategy
+							        .getDeadLetterQueueFor(message
+							                .getDestination());
+							BrokerSupport.resend(context,message,
+							        deadLetterDestination);
+							sent=true;
+						}
+					}
+				}
+			}
+			if(sent==false){
+				LOG.warn("Failed to send "+node+" to dead letter queue");
+			}
+		}catch(Exception e){
+			LOG.warn("Failed to pass expired message to dead letter queue",e);
+		}
+	}
 
     public Broker getRoot() {
         try {



Mime
View raw message