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/29 09:14:57 UTC

svn commit: r958852 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/component/direct/DirectProducer.java test/java/org/apache/camel/component/direct/SendToNonExistingDirectEndpointTest.java

Author: davsclaus
Date: Tue Jun 29 07:14:57 2010
New Revision: 958852

URL: http://svn.apache.org/viewvc?rev=958852&view=rev
Log:
CAMEL-2873: Direct endpoint throws exception if sending to a non existing endpoint

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/direct/SendToNonExistingDirectEndpointTest.java   (with props)
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/direct/DirectProducer.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/direct/DirectProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/direct/DirectProducer.java?rev=958852&r1=958851&r2=958852&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/direct/DirectProducer.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/direct/DirectProducer.java Tue Jun 29 07:14:57 2010
@@ -18,6 +18,7 @@ package org.apache.camel.component.direc
 
 import org.apache.camel.AsyncCallback;
 import org.apache.camel.AsyncProcessor;
+import org.apache.camel.CamelExchangeException;
 import org.apache.camel.Exchange;
 import org.apache.camel.impl.DefaultProducer;
 import org.apache.camel.impl.converter.AsyncProcessorTypeConverter;
@@ -41,6 +42,7 @@ public class DirectProducer extends Defa
     public void process(Exchange exchange) throws Exception {
         if (endpoint.getConsumer() == null) {
             LOG.warn("No consumers available on endpoint: " + endpoint + " to process: " + exchange);
+            throw new CamelExchangeException("No consumers available on endpoint: " + endpoint, exchange);
         } else {
             endpoint.getConsumer().getProcessor().process(exchange);
         }
@@ -50,6 +52,7 @@ public class DirectProducer extends Defa
         if (endpoint.getConsumer() == null) {
             LOG.warn("No consumers available on endpoint: " + endpoint + " to process: " + exchange);
             // indicate its done synchronously
+            exchange.setException(new CamelExchangeException("No consumers available on endpoint: " + endpoint, exchange));
             callback.done(true);
             return true;
         } else {

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/direct/SendToNonExistingDirectEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/direct/SendToNonExistingDirectEndpointTest.java?rev=958852&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/direct/SendToNonExistingDirectEndpointTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/direct/SendToNonExistingDirectEndpointTest.java Tue Jun 29 07:14:57 2010
@@ -0,0 +1,43 @@
+/**
+ * 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.direct;
+
+import org.apache.camel.CamelExchangeException;
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.ContextTestSupport;
+
+/**
+ * @version $Revision$
+ */
+public class SendToNonExistingDirectEndpointTest extends ContextTestSupport {
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    public void testDirect() throws Exception {
+        try {
+            template.sendBody("direct:foo", "Hello World");
+            fail("Should have thrown exception");
+        } catch (CamelExecutionException e) {
+            CamelExchangeException cause = assertIsInstanceOf(CamelExchangeException.class, e.getCause());
+            assertEquals("No consumers available on endpoint: Endpoint[direct://foo]. Exchange[Message: Hello World]", cause.getMessage());
+            assertNotNull(cause.getExchange());
+        }
+    }
+}

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

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