You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/07/03 06:09:52 UTC

[1/5] git commit: Removed the unused import of RabbitMQConsumer

Repository: camel
Updated Branches:
  refs/heads/master 76ddb85f5 -> 624b1abc7


Removed the unused import of RabbitMQConsumer


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8bd6e7ab
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8bd6e7ab
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8bd6e7ab

Branch: refs/heads/master
Commit: 8bd6e7ab793895a9fb21230ad8a12ed2d8c788ec
Parents: 76ddb85
Author: Willem Jiang <wi...@gmail.com>
Authored: Thu Jul 3 10:58:52 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Thu Jul 3 10:58:52 2014 +0800

----------------------------------------------------------------------
 .../java/org/apache/camel/component/rabbitmq/RabbitMQConsumer.java  | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8bd6e7ab/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQConsumer.java b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQConsumer.java
index 2539b14..7d8b4d1 100644
--- a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQConsumer.java
+++ b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQConsumer.java
@@ -27,7 +27,6 @@ import com.rabbitmq.client.AMQP;
 import com.rabbitmq.client.Channel;
 import com.rabbitmq.client.Connection;
 import com.rabbitmq.client.Envelope;
-import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.impl.DefaultConsumer;


[5/5] git commit: CAMEL-7570 Added an unit test for it

Posted by ni...@apache.org.
CAMEL-7570 Added an unit test for it


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/624b1abc
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/624b1abc
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/624b1abc

Branch: refs/heads/master
Commit: 624b1abc7e9962b9adae62287f48147578ab50fc
Parents: c5329ea
Author: Willem Jiang <wi...@gmail.com>
Authored: Thu Jul 3 12:09:32 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Thu Jul 3 12:09:32 2014 +0800

----------------------------------------------------------------------
 .../enricher/EnricherSendEventTest.java         | 118 +++++++++++++++++++
 1 file changed, 118 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/624b1abc/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherSendEventTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherSendEventTest.java b/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherSendEventTest.java
new file mode 100644
index 0000000..9072be6
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherSendEventTest.java
@@ -0,0 +1,118 @@
+/**
+ * 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.processor.enricher;
+
+import java.util.EventObject;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.management.DefaultManagementStrategy;
+import org.apache.camel.management.event.ExchangeSendingEvent;
+import org.apache.camel.management.event.ExchangeSentEvent;
+import org.apache.camel.processor.async.MyAsyncComponent;
+import org.apache.camel.spi.ManagementStrategy;
+import org.apache.camel.spi.ShutdownStrategy;
+import org.apache.camel.support.EventNotifierSupport;
+
+
+public class EnricherSendEventTest extends ContextTestSupport {
+    private MyEventNotifier en = new MyEventNotifier();
+    
+    public void testAsyncEnricher() throws Exception {
+        
+        template.sendBody("direct:start1", "test");
+        assertEquals("Get a wrong sending event number", 3, en.exchangeSendingEvent.get());
+        assertEquals("Get a wrong sent event number", 3, en.exchangeSentEvent.get());
+    }
+    
+    
+    public void testSyncEnricher() throws Exception {
+        template.sendBody("direct:start2", "test");
+        assertEquals("Get a wrong sending event number", 3, en.exchangeSendingEvent.get());
+        assertEquals("Get a wrong sent event number", 3, en.exchangeSentEvent.get());
+    }
+    
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+        ShutdownStrategy shutdownStrategy = camelContext.getShutdownStrategy();
+        camelContext.addComponent("async", new MyAsyncComponent());
+        
+        shutdownStrategy.setTimeout(1000);
+        shutdownStrategy.setTimeUnit(TimeUnit.MILLISECONDS);
+        shutdownStrategy.setShutdownNowOnTimeout(true);
+       
+
+        ManagementStrategy managementStrategy = new DefaultManagementStrategy();
+        managementStrategy.addEventNotifier(en);
+        
+        camelContext.setManagementStrategy(managementStrategy);
+        return camelContext;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("direct:start1")
+                    // using the async utility component to ensure that the async routing engine kicks in
+                    .enrich("async:out?reply=Reply")
+                    .to("mock:result");
+                
+                from("direct:start2")
+                    .enrich("direct:result")
+                    .to("mock:result");
+                
+                from("direct:result").setBody(constant("result"));
+            }
+        };
+    }
+    
+    static class MyEventNotifier extends EventNotifierSupport {
+        
+        AtomicInteger exchangeSendingEvent = new AtomicInteger();
+        AtomicInteger exchangeSentEvent = new AtomicInteger();
+      
+        
+        @Override
+        public void notify(EventObject event) throws Exception {
+            
+            if (event instanceof ExchangeSendingEvent) {
+                exchangeSendingEvent.incrementAndGet();
+            } else if (event instanceof ExchangeSentEvent) {
+                exchangeSentEvent.incrementAndGet();
+            }
+        }
+
+        @Override
+        public boolean isEnabled(EventObject event) {
+            return true;
+        }
+
+        @Override
+        protected void doStart() throws Exception {
+        }
+
+        @Override
+        protected void doStop() throws Exception {
+        }
+    }
+
+
+}


[4/5] git commit: CAMEL-7569 Fixed the CS error

Posted by ni...@apache.org.
CAMEL-7569 Fixed the CS error


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c5329ead
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c5329ead
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c5329ead

Branch: refs/heads/master
Commit: c5329ead5679547b38a1360ad441a586b00af8e5
Parents: bbd999f
Author: Willem Jiang <wi...@gmail.com>
Authored: Thu Jul 3 11:33:32 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Thu Jul 3 11:33:32 2014 +0800

----------------------------------------------------------------------
 .../src/main/java/org/apache/camel/impl/DefaultCamelContext.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c5329ead/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
index 4b0b814..250ff4f 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
@@ -1058,7 +1058,7 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon
         } else if ("cxfrs".equals(componentName)) {
             return "cxf/jaxrs";
         } else if ("gauth".equals(componentName) || "ghttp".equals(componentName) || "glogin".equals(componentName)
-                ||"gmail".equals(componentName) || "gtask".equals(componentName) ) {
+                || "gmail".equals(componentName) || "gtask".equals(componentName)) {
             return "gae/" + componentName.substring(1);
         }
         return componentName.replaceAll("-", "");


[3/5] git commit: CAMEL-7504 Fixed the CS error

Posted by ni...@apache.org.
CAMEL-7504 Fixed the CS error


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/bbd999ff
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/bbd999ff
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/bbd999ff

Branch: refs/heads/master
Commit: bbd999ff7190a75fa14e64c478ff3fbd09a607db
Parents: 53fe845
Author: Willem Jiang <wi...@gmail.com>
Authored: Thu Jul 3 11:32:57 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Thu Jul 3 11:32:57 2014 +0800

----------------------------------------------------------------------
 .../org/apache/camel/processor/Throttler.java   |  6 ++---
 .../ThrottlerRejectedExecutionException.java    | 23 +++++++++++++++-----
 .../apache/camel/processor/ThrottlerTest.java   |  7 +++---
 3 files changed, 25 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/bbd999ff/camel-core/src/main/java/org/apache/camel/processor/Throttler.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/Throttler.java b/camel-core/src/main/java/org/apache/camel/processor/Throttler.java
index 2ec37e4..f70325d 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/Throttler.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/Throttler.java
@@ -16,6 +16,9 @@
  */
 package org.apache.camel.processor;
 
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.atomic.AtomicLong;
+
 import org.apache.camel.AsyncCallback;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
@@ -25,9 +28,6 @@ import org.apache.camel.RuntimeExchangeException;
 import org.apache.camel.Traceable;
 import org.apache.camel.util.ObjectHelper;
 
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.atomic.AtomicLong;
-
 /**
  * A <a href="http://camel.apache.org/throttler.html">Throttler</a>
  * will set a limit on the maximum number of message exchanges which can be sent

http://git-wip-us.apache.org/repos/asf/camel/blob/bbd999ff/camel-core/src/main/java/org/apache/camel/processor/ThrottlerRejectedExecutionException.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/ThrottlerRejectedExecutionException.java b/camel-core/src/main/java/org/apache/camel/processor/ThrottlerRejectedExecutionException.java
index 6790760..bdda105 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/ThrottlerRejectedExecutionException.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/ThrottlerRejectedExecutionException.java
@@ -1,13 +1,26 @@
+/**
+ * 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.processor;
 
 import java.util.concurrent.RejectedExecutionException;
 
-/**
- * Created by david on 02/07/14.
- */
+
 public class ThrottlerRejectedExecutionException
-    extends RejectedExecutionException
-{
+    extends RejectedExecutionException {
     public ThrottlerRejectedExecutionException(String message) {
         super(message);
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/bbd999ff/camel-core/src/test/java/org/apache/camel/processor/ThrottlerTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/ThrottlerTest.java b/camel-core/src/test/java/org/apache/camel/processor/ThrottlerTest.java
index f18631a..31ecd58 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/ThrottlerTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/ThrottlerTest.java
@@ -16,17 +16,18 @@
  */
 package org.apache.camel.processor;
 
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.DefaultExchange;
 import org.apache.camel.processor.Throttler.TimeSlot;
 
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
 import static org.apache.camel.builder.Builder.constant;
 
+
 /**
  * @version
  */


[2/5] git commit: CAMEL-7570 Fixed the issue that enrich doesn't send out ExchangeSendingEvent nor ExchangeSentEvent

Posted by ni...@apache.org.
CAMEL-7570 Fixed the issue that enrich doesn't send out ExchangeSendingEvent nor ExchangeSentEvent


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/53fe8451
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/53fe8451
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/53fe8451

Branch: refs/heads/master
Commit: 53fe84513ae6948a0590f4b45357fb4660c465b3
Parents: 8bd6e7a
Author: Willem Jiang <wi...@gmail.com>
Authored: Thu Jul 3 11:31:52 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Thu Jul 3 11:31:52 2014 +0800

----------------------------------------------------------------------
 .../java/org/apache/camel/processor/Enricher.java | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/53fe8451/camel-core/src/main/java/org/apache/camel/processor/Enricher.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/Enricher.java b/camel-core/src/main/java/org/apache/camel/processor/Enricher.java
index 092e4d2..72faa12 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/Enricher.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/Enricher.java
@@ -19,6 +19,7 @@ package org.apache.camel.processor;
 import org.apache.camel.AsyncCallback;
 import org.apache.camel.AsyncProcessor;
 import org.apache.camel.CamelExchangeException;
+import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.Producer;
@@ -27,11 +28,12 @@ import org.apache.camel.processor.aggregate.AggregationStrategy;
 import org.apache.camel.support.ServiceSupport;
 import org.apache.camel.util.AsyncProcessorConverterHelper;
 import org.apache.camel.util.AsyncProcessorHelper;
+import org.apache.camel.util.EventHelper;
 import org.apache.camel.util.ExchangeHelper;
 import org.apache.camel.util.ServiceHelper;
+import org.apache.camel.util.StopWatch;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
 import static org.apache.camel.util.ExchangeHelper.copyResultsPreservePattern;
 
 /**
@@ -109,7 +111,11 @@ public class Enricher extends ServiceSupport implements AsyncProcessor {
      */
     public boolean process(final Exchange exchange, final AsyncCallback callback) {
         final Exchange resourceExchange = createResourceExchange(exchange, ExchangePattern.InOut);
-
+        final Endpoint destination = producer.getEndpoint();
+        
+        EventHelper.notifyExchangeSending(exchange.getContext(), resourceExchange, destination);
+        // record timing for sending the exchange using the producer
+        final StopWatch watch = new StopWatch();
         AsyncProcessor ap = AsyncProcessorConverterHelper.convert(producer);
         boolean sync = ap.process(resourceExchange, new AsyncCallback() {
             public void done(boolean doneSync) {
@@ -118,6 +124,10 @@ public class Enricher extends ServiceSupport implements AsyncProcessor {
                     return;
                 }
 
+                // emit event that the exchange was sent to the endpoint
+                long timeTaken = watch.stop();
+                EventHelper.notifyExchangeSent(resourceExchange.getContext(), resourceExchange, destination, timeTaken);
+                
                 if (resourceExchange.isFailed()) {
                     // copy resource exchange onto original exchange (preserving pattern)
                     copyResultsPreservePattern(exchange, resourceExchange);
@@ -157,6 +167,10 @@ public class Enricher extends ServiceSupport implements AsyncProcessor {
 
         LOG.trace("Processing exchangeId: {} is continued being processed synchronously", exchange.getExchangeId());
 
+        // emit event that the exchange was sent to the endpoint
+        long timeTaken = watch.stop();
+        EventHelper.notifyExchangeSent(resourceExchange.getContext(), resourceExchange, destination, timeTaken);
+        
         if (resourceExchange.isFailed()) {
             // copy resource exchange onto original exchange (preserving pattern)
             copyResultsPreservePattern(exchange, resourceExchange);