camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r751447 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/model/ main/java/org/apache/camel/processor/ test/java/org/apache/camel/component/file/
Date Sun, 08 Mar 2009 15:32:29 GMT
Author: davsclaus
Date: Sun Mar  8 15:32:29 2009
New Revision: 751447

URL: http://svn.apache.org/viewvc?rev=751447&view=rev
Log:
CAMEL-1435: Stacktraces can be turned off on DLC.

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileAbsoluteAndRelativeConsumer.java
  (with props)
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/RedeliveryPolicyDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryPolicy.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/RedeliveryPolicyDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RedeliveryPolicyDefinition.java?rev=751447&r1=751446&r2=751447&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/RedeliveryPolicyDefinition.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/RedeliveryPolicyDefinition.java
Sun Mar  8 15:32:29 2009
@@ -54,6 +54,8 @@
     private LoggingLevel retriesExhaustedLogLevel;
     @XmlAttribute
     private LoggingLevel retryAttemptedLogLevel;
+    @XmlAttribute
+    private Boolean logStackTrace;
 
     public RedeliveryPolicy createRedeliveryPolicy(CamelContext context, RedeliveryPolicy
parentPolicy) {
         if (ref != null) {
@@ -91,6 +93,9 @@
         if (maximumRedeliveryDelay != null) {
             answer.setMaximumRedeliveryDelay(maximumRedeliveryDelay);
         }
+        if (logStackTrace != null) {
+            answer.setLogStackTrace(logStackTrace);
+        }
         return answer;
     }
 
@@ -165,6 +170,19 @@
         setRetryAttemptedLogLevel(retryAttemptedLogLevel);
         return this;
     }
+
+    /**
+     * Sets wheter stack traces should be logged, can be used to reduce verbose.
+     *
+     * @param logStackTrace  wheter stack traces should be logged or not
+     * @return the builder
+     */
+    public RedeliveryPolicyDefinition logStackTrace(boolean logStackTrace) {
+        setLogStackTrace(logStackTrace);
+        return this;
+    }
+
+
         
     /**
      * Sets the maximum redeliveries
@@ -306,4 +324,12 @@
     public void setRef(String ref) {
         this.ref = ref;
     }
+
+    public Boolean getLogStackTrace() {
+        return logStackTrace;
+    }
+
+    public void setLogStackTrace(Boolean logStackTrace) {
+        this.logStackTrace = logStackTrace;
+    }
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java?rev=751447&r1=751446&r2=751447&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java
Sun Mar  8 15:32:29 2009
@@ -427,7 +427,7 @@
         } else {
             newLogLevel = data.currentRedeliveryPolicy.getRetriesExhaustedLogLevel();
         }
-        if (e != null) {
+        if (data.currentRedeliveryPolicy.isLogStackTrace() && e != null) {
             logger.log(message, e, newLogLevel);
         } else {
             logger.log(message, newLogLevel);

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryPolicy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryPolicy.java?rev=751447&r1=751446&r2=751447&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryPolicy.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryPolicy.java
Sun Mar  8 15:32:29 2009
@@ -44,6 +44,7 @@
  *   <li>useCollisionAvoidance = false</li>
  *   <li>retriesExhaustedLogLevel = LoggingLevel.ERROR</li>
  *   <li>retryAttemptedLogLevel = LoggingLevel.ERROR</li>
+ *   <li>logStrackTrace = true</li>
  * </ul>
  * <p/>
  * Setting the maximumRedeliveries to a negative value such as -1 will then always redeliver
(unlimited).
@@ -81,6 +82,7 @@
     protected boolean useCollisionAvoidance;
     protected LoggingLevel retriesExhaustedLogLevel = LoggingLevel.ERROR;
     protected LoggingLevel retryAttemptedLogLevel = LoggingLevel.ERROR;
+    protected boolean logStackTrace = true;
     protected String delayPattern;
 
     public RedeliveryPolicy() {
@@ -93,6 +95,7 @@
             + ", maximumRedeliveryDelay=" + maximumRedeliveryDelay
             + ", retriesExhaustedLogLevel=" + retriesExhaustedLogLevel
             + ", retryAttemptedLogLevel=" + retryAttemptedLogLevel
+            + ", logTraceStace=" + logStackTrace
             + ", useExponentialBackOff="  + useExponentialBackOff
             + ", backOffMultiplier=" + backOffMultiplier
             + ", useCollisionAvoidance=" + useCollisionAvoidance
@@ -282,6 +285,14 @@
     }    
     
     /**
+     * Sets the logging level to use for log messages when retries are attempted.
+     */
+    public RedeliveryPolicy logStackTrace(boolean logStackTrace) {
+        setLogStackTrace(logStackTrace);
+        return this;
+    }
+
+    /**
      * Sets the delay pattern with delay intervals.
      */
     public RedeliveryPolicy delayPattern(String delayPattern) {
@@ -414,4 +425,15 @@
     public void setDelayPattern(String delayPattern) {
         this.delayPattern = delayPattern;
     }
+
+    public boolean isLogStackTrace() {
+        return logStackTrace;
+    }
+
+    /**
+     * Sets wheter stack traces should be logged or not
+     */
+    public void setLogStackTrace(boolean logStackTrace) {
+        this.logStackTrace = logStackTrace;
+    }
 }

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileAbsoluteAndRelativeConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileAbsoluteAndRelativeConsumer.java?rev=751447&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileAbsoluteAndRelativeConsumer.java
(added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileAbsoluteAndRelativeConsumer.java
Sun Mar  8 15:32:29 2009
@@ -0,0 +1,77 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.file;
+
+import java.io.File;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * @version $Revision$
+ */
+public class FileAbsoluteAndRelativeConsumer extends ContextTestSupport {
+
+    private String base;
+
+    @Override
+    protected void setUp() throws Exception {
+        deleteDirectory("target/filerelative");
+        deleteDirectory("target/fileabsolute");
+        // use current dir as base as aboslute path
+        base = new File("").getAbsolutePath() + "/target/fileabsolute";
+        super.setUp();
+    }
+
+    public void testRelative() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:relative");
+        mock.expectedMessageCount(1);
+
+        mock.message(0).header(Exchange.FILE_NAME).isEqualTo("test" + File.separator + "hello.txt");
+        mock.message(0).header(Exchange.FILE_NAME_ONLY).isEqualTo("hello.txt");
+
+        template.sendBodyAndHeader("file://target/filerelative", "Hello World", Exchange.FILE_NAME,
"test/hello.txt");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testAbsolute() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:absolute");
+        mock.expectedMessageCount(1);
+
+        mock.message(0).header(Exchange.FILE_NAME).isEqualTo("test" + File.separator + "hello.txt");
+        mock.message(0).header(Exchange.FILE_NAME_ONLY).isEqualTo("hello.txt");
+
+        template.sendBodyAndHeader("file://target/fileabsolute", "Hello World", Exchange.FILE_NAME,
"test/hello.txt");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("file://target/filerelative?recursive=true").to("mock:relative");
+
+                from("file://" + base + "?recursive=true").to("mock:absolute");
+            }
+        };
+    }
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileAbsoluteAndRelativeConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileAbsoluteAndRelativeConsumer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message