You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2010/06/19 14:23:57 UTC
svn commit: r956218 - in /camel/trunk:
camel-core/src/main/java/org/apache/camel/
camel-core/src/main/java/org/apache/camel/impl/
camel-core/src/main/java/org/apache/camel/processor/
camel-core/src/main/java/org/apache/camel/processor/loadbalancer/ com...
Author: davsclaus
Date: Sat Jun 19 12:23:56 2010
New Revision: 956218
URL: http://svn.apache.org/viewvc?rev=956218&view=rev
Log:
Polished setException on Exchange a bit.
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Pipeline.java
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/FailOverLoadBalancer.java
camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/RichExchange.scala
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java?rev=956218&r1=956217&r2=956218&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java Sat Jun 19 12:23:56 2010
@@ -296,13 +296,9 @@ public interface Exchange {
/**
* Sets the exception associated with this exchange
- *
- * @param e the caused exception
- */
- void setException(Exception e);
-
- /**
- * Sets the exception associated with this exchange
+ * <p/>
+ * Camel will wrap {@link Throwable} into {@link Exception} type to
+ * accommodate for the {@link #getException()} method returning a plain {@link Exception} type.
*
* @param t the caused exception
*/
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java?rev=956218&r1=956217&r2=956218&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java Sat Jun 19 12:23:56 2010
@@ -248,12 +248,10 @@ public final class DefaultExchange imple
return ObjectHelper.getException(type, exception);
}
- public void setException(Exception exception) {
- this.exception = exception;
- }
-
public void setException(Throwable t) {
- if (t instanceof Exception) {
+ if (t == null) {
+ this.exception = null;
+ } else if (t instanceof Exception) {
this.exception = (Exception) t;
} else {
// wrap throwable into an exception
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Pipeline.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Pipeline.java?rev=956218&r1=956217&r2=956218&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Pipeline.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Pipeline.java Sat Jun 19 12:23:56 2010
@@ -245,7 +245,7 @@ public class Pipeline extends MulticastP
@Override
public String toString() {
- return "Pipeline" + getProcessors();
+ return "Pipeline[" + getProcessors() + "]";
}
@Override
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java?rev=956218&r1=956217&r2=956218&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java Sat Jun 19 12:23:56 2010
@@ -395,9 +395,7 @@ public abstract class RedeliveryErrorHan
protected void prepareExchangeForRedelivery(Exchange exchange) {
// okay we will give it another go so clear the exception so we can try again
- if (exchange.getException() != null) {
- exchange.setException(null);
- }
+ exchange.setException(null);
// clear rollback flags
exchange.setProperty(Exchange.ROLLBACK_ONLY, null);
@@ -457,7 +455,7 @@ public abstract class RedeliveryErrorHan
// run this synchronously as its just a Processor
try {
data.onRedeliveryProcessor.process(exchange);
- } catch (Exception e) {
+ } catch (Throwable e) {
exchange.setException(e);
}
log.trace("Redelivery processor done");
@@ -748,7 +746,7 @@ public abstract class RedeliveryErrorHan
if (executorService == null || executorService.isShutdown()) {
// camel context will shutdown the executor when it shutdown so no need to shut it down when stopping
executorService = camelContext.getExecutorServiceStrategy().newScheduledThreadPool(this,
- getClass().getSimpleName() + "-AsyncRedeliveryTask", poolSize);
+ "RedeliveryErrorHandler-AsyncRedeliveryTask", poolSize);
}
}
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/FailOverLoadBalancer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/FailOverLoadBalancer.java?rev=956218&r1=956217&r2=956218&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/FailOverLoadBalancer.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/FailOverLoadBalancer.java Sat Jun 19 12:23:56 2010
@@ -24,6 +24,7 @@ import org.apache.camel.AsyncProcessor;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.impl.converter.AsyncProcessorTypeConverter;
+import org.apache.camel.processor.Traceable;
import org.apache.camel.util.ObjectHelper;
/**
@@ -33,7 +34,7 @@ import org.apache.camel.util.ObjectHelpe
* as the failover load balancer is a specialized pipeline. So the trick is to keep doing the same as the
* pipeline to ensure it works the same and the async routing engine is flawless.
*/
-public class FailOverLoadBalancer extends LoadBalancerSupport {
+public class FailOverLoadBalancer extends LoadBalancerSupport implements Traceable {
private final List<Class<?>> exceptions;
private boolean roundRobin;
@@ -163,7 +164,7 @@ public class FailOverLoadBalancer extend
if (log.isTraceEnabled()) {
log.trace("Processing exchangeId: " + exchange.getExchangeId() + " is continued being processed asynchronously");
}
- // the remainder of the pipeline will be completed async
+ // the remainder of the failover will be completed async
// so we break out now, then the callback will be invoked which then continue routing from where we left here
return false;
}
@@ -174,9 +175,6 @@ public class FailOverLoadBalancer extend
}
if (log.isTraceEnabled()) {
- // logging nextExchange as it contains the exchange that might have altered the payload and since
- // we are logging the completion if will be confusing if we log the original instead
- // we could also consider logging the original and the nextExchange then we have *before* and *after* snapshots
log.trace("Failover complete for exchangeId: " + exchange.getExchangeId() + " >>> " + exchange);
}
@@ -206,7 +204,7 @@ public class FailOverLoadBalancer extend
throw new IllegalStateException("No processors could be chosen to process " + exchange);
}
if (log.isDebugEnabled()) {
- log.debug("Processing failover at attempt " + attempts + " for exchange: " + exchange);
+ log.debug("Processing failover at attempt " + attempts + " for " + exchange);
}
AsyncProcessor albp = AsyncProcessorTypeConverter.convert(processor);
@@ -275,7 +273,7 @@ public class FailOverLoadBalancer extend
if (log.isTraceEnabled()) {
log.trace("Processing exchangeId: " + exchange.getExchangeId() + " is continued being processed asynchronously");
}
- // the remainder of the pipeline will be completed async
+ // the remainder of the failover will be completed async
// so we break out now, then the callback will be invoked which then continue routing from where we left here
return;
}
@@ -287,7 +285,10 @@ public class FailOverLoadBalancer extend
}
public String toString() {
- return "FailoverLoadBalancer";
+ return "FailoverLoadBalancer[" + getProcessors() + "]";
}
+ public String getTraceLabel() {
+ return "failover";
+ }
}
Modified: camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/RichExchange.scala
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/RichExchange.scala?rev=956218&r1=956217&r2=956218&view=diff
==============================================================================
--- camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/RichExchange.scala (original)
+++ camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/RichExchange.scala Sat Jun 19 12:23:56 2010
@@ -58,8 +58,6 @@ class RichExchange(val exchange : Exchan
def setExchangeId(id: String) = exchange.setExchangeId(id)
- def setException(e: Exception) = exchange.setException(e)
-
def setException(t: Throwable) = exchange.setException(t)
def removeProperty(name: String) = exchange.removeProperty(name)