camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r881699 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/component/timer/ camel-core/src/test/java/org/apache/camel/processor/interceptor/ components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/ components/cam...
Date Wed, 18 Nov 2009 08:43:44 GMT
Author: davsclaus
Date: Wed Nov 18 08:43:44 2009
New Revision: 881699

URL: http://svn.apache.org/viewvc?rev=881699&view=rev
Log:
CAMEL-2186: Timer and Quartz will now log ERROR if the Exchange completed with an Exception.
FTP producer will log at WARN if writing a file failed.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/timer/TimerConsumer.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTest.java
    camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java
    camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/CamelJob.java
    camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzConsumer.java
    camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzEndpoint.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/timer/TimerConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/timer/TimerConsumer.java?rev=881699&r1=881698&r2=881699&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/timer/TimerConsumer.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/timer/TimerConsumer.java
Wed Nov 18 08:43:44 2009
@@ -23,6 +23,7 @@
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.impl.DefaultConsumer;
+import org.apache.camel.util.ExchangeHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -92,7 +93,7 @@
 
         Date now = new Date();
         exchange.setProperty(Exchange.TIMER_FIRED_TIME, now);
-        // also set now on in header with same key as quaartz to be consistent
+        // also set now on in header with same key as quartz to be consistent
         exchange.getIn().setHeader("firedTime", now);
 
         if (LOG.isTraceEnabled()) {
@@ -100,6 +101,11 @@
         }
         try {
             getProcessor().process(exchange);
+
+            // log exception if an exception occurred and was not handled
+            if (exchange.getException() != null) {
+                handleException(exchange.getException());
+            }
         } catch (Exception e) {
             handleException(e);
         }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTest.java?rev=881699&r1=881698&r2=881699&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTest.java
Wed Nov 18 08:43:44 2009
@@ -53,6 +53,25 @@
         assertMockEndpointsSatisfied();
     }
 
+    public void testAdvisedNoNewRoutesAllowed() throws Exception {
+        try {
+            context.getRouteDefinitions().get(0).adviceWith(new RouteBuilder() {
+                @Override
+                public void configure() throws Exception {
+                    from("direct:bar").to("mock:bar");
+
+                    interceptSendToEndpoint("mock:foo")
+                            .skipSendToOriginalEndpoint()
+                            .to("log:foo")
+                            .to("mock:advised");
+                }
+            });
+            fail("Should have thrown exception");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+    }
+
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {

Modified: camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java?rev=881699&r1=881698&r2=881699&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java
(original)
+++ camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileProducer.java
Wed Nov 18 08:43:44 2009
@@ -66,14 +66,14 @@
             // if we are stopping then ignore any exception during a poll
             log.debug("Exception occurred during stopping: " + exception.getMessage());
         } else {
-            log.debug("Exception occurred during processing. ", exception);
+            log.warn("Writing file failed with: " + exception.getMessage());
             try {
                 disconnect();
             } catch (Exception e) {
                 // ignore exception
-                log.debug("Ignored exception during disconnect", e);
+                log.debug("Ignored exception during disconnect: " + e.getMessage());
             }
-            // Rethrow the original exception
+            // rethrow the original exception*/
             throw exception;
         }
     }

Modified: camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/CamelJob.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/CamelJob.java?rev=881699&r1=881698&r2=881699&view=diff
==============================================================================
--- camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/CamelJob.java
(original)
+++ camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/CamelJob.java
Wed Nov 18 08:43:44 2009
@@ -24,6 +24,7 @@
  * @version $Revision$
  */
 public class CamelJob implements Job {
+
     public void execute(JobExecutionContext context) throws JobExecutionException {
         QuartzEndpoint component = (QuartzEndpoint) context.getJobDetail().getJobDataMap().get(QuartzConstants.QUARTZ_ENDPOINT);
         if (component == null) {

Modified: camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzConsumer.java?rev=881699&r1=881698&r2=881699&view=diff
==============================================================================
--- camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzConsumer.java
(original)
+++ camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzConsumer.java
Wed Nov 18 08:43:44 2009
@@ -23,6 +23,7 @@
  * @version $Revision$
  */
 public class QuartzConsumer extends DefaultConsumer {
+
     public QuartzConsumer(QuartzEndpoint endpoint, Processor processor) {
         super(endpoint, processor);
     }

Modified: camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzEndpoint.java?rev=881699&r1=881698&r2=881699&view=diff
==============================================================================
--- camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzEndpoint.java
(original)
+++ camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzEndpoint.java
Wed Nov 18 08:43:44 2009
@@ -101,6 +101,11 @@
         Exchange exchange = createExchange(jobExecutionContext);
         try {
             getLoadBalancer().process(exchange);
+
+            // log exception if an exception occurred and was not handled
+            if (exchange.getException() != null) {
+                LOG.error("Quart Job processing Exchange: " + exchange + " failed with exception.",
exchange.getException());
+            }
         } catch (JobExecutionException e) {
             throw e;
         } catch (Exception e) {



Mime
View raw message