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 2016/07/24 13:47:27 UTC
[1/4] camel git commit: CAMEL-10172: Make BeanProducer fully async
Repository: camel
Updated Branches:
refs/heads/master 5774dc452 -> 2d0de2bbf
CAMEL-10172: Make BeanProducer fully async
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d7cb730d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d7cb730d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d7cb730d
Branch: refs/heads/master
Commit: d7cb730ddc9d082f2c5006f68ca5aaa5ce355020
Parents: 5774dc4
Author: Vitalii Tymchyshyn <vi...@tym.im>
Authored: Thu Jul 21 23:21:04 2016 -0400
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Jul 24 13:48:16 2016 +0200
----------------------------------------------------------------------
.../camel/component/bean/BeanProducer.java | 8 +-
...cEndpointRoutingSlipBeanNonBlockingTest.java | 122 +++++++++++++++++++
2 files changed, 123 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/d7cb730d/camel-core/src/main/java/org/apache/camel/component/bean/BeanProducer.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/bean/BeanProducer.java b/camel-core/src/main/java/org/apache/camel/component/bean/BeanProducer.java
index 1f2704e..36a6ef3 100644
--- a/camel-core/src/main/java/org/apache/camel/component/bean/BeanProducer.java
+++ b/camel-core/src/main/java/org/apache/camel/component/bean/BeanProducer.java
@@ -38,13 +38,7 @@ public class BeanProducer extends DefaultAsyncProducer {
@Override
public boolean process(Exchange exchange, AsyncCallback callback) {
- try {
- processor.process(exchange);
- } catch (Exception e) {
- exchange.setException(e);
- }
- callback.done(true);
- return true;
+ return processor.process(exchange, callback);
}
@Override
http://git-wip-us.apache.org/repos/asf/camel/blob/d7cb730d/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointRoutingSlipBeanNonBlockingTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointRoutingSlipBeanNonBlockingTest.java b/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointRoutingSlipBeanNonBlockingTest.java
new file mode 100644
index 0000000..7b8eab3
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointRoutingSlipBeanNonBlockingTest.java
@@ -0,0 +1,122 @@
+/**
+ * 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.async;
+
+import org.apache.camel.*;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.processor.SendProcessor;
+import org.apache.camel.util.AsyncProcessorHelper;
+import org.apache.camel.util.ServiceHelper;
+import org.junit.Assert;
+
+import java.util.concurrent.*;
+
+/**
+ * @version
+ */
+public class AsyncEndpointRoutingSlipBeanNonBlockingTest extends ContextTestSupport {
+ private AsyncCallback innerCallback;
+ private Exchange innerExchange;
+
+ @Override
+ protected JndiRegistry createRegistry() throws Exception {
+ JndiRegistry jndi = super.createRegistry();
+ jndi.bind("myBean", new MyRoutingSlipBean());
+ return jndi;
+ }
+
+ public void testAsyncEndpointDontBlock() throws Exception {
+ getMockEndpoint("mock:result").expectedBodiesReceived("Bye Camel");
+ Endpoint startEndpoint = context.getEndpoint("direct:start");
+ SendProcessor asyncSender = new SendProcessor(startEndpoint);
+ ServiceHelper.startService(asyncSender);
+
+ ExecutorService executorService = context.getExecutorServiceManager().newSingleThreadExecutor(this, "test");
+ try {
+ Future<Boolean> asyncFuture = executorService.submit(new ExchangeSubmitter(startEndpoint, asyncSender));
+ Assert.assertFalse(asyncFuture.get(5, TimeUnit.SECONDS));
+ innerExchange.getOut().setBody("Bye Camel");
+ innerCallback.done(false);
+
+ assertMockEndpointsSatisfied();
+ } finally {
+ executorService.shutdown();
+ ServiceHelper.stopAndShutdownService(asyncSender);
+ }
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ context.addComponent("async", new MyAsyncComponent());
+
+ from("direct:start")
+ .to("bean:myBean");
+ from("direct:asyncRoute")
+ .process(new MyAsyncProcessor());
+ }
+ };
+ }
+
+ public static class MyRoutingSlipBean {
+
+ @RoutingSlip
+ public String doSomething() {
+ return "direct:asyncRoute,mock:result";
+ }
+ }
+
+ private static class ExchangeSubmitter implements Callable<Boolean> {
+ private final Endpoint startEndpoint;
+ private final SendProcessor asyncSender;
+
+ public ExchangeSubmitter(Endpoint startEndpoint, SendProcessor asyncSender) {
+ this.startEndpoint = startEndpoint;
+ this.asyncSender = asyncSender;
+ }
+
+ @Override
+ public Boolean call() throws Exception {
+ Exchange exchange = startEndpoint.createExchange(ExchangePattern.InOut);
+ exchange.getIn().setBody("Hello Camel");
+ return asyncSender.process(exchange, new AsyncCallback() {
+ @Override
+ public void done(boolean doneSync) {
+ Assert.assertFalse(doneSync);
+ }
+ });
+ }
+ }
+
+ private class MyAsyncProcessor implements AsyncProcessor {
+ @Override
+ public boolean process(Exchange exchange, AsyncCallback callback) {
+ innerCallback = callback;
+ innerExchange = exchange;
+
+ return false;
+ }
+
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ AsyncProcessorHelper.process(this, exchange);
+ }
+ }
+}
\ No newline at end of file
[2/4] camel git commit: Fixed CS. This closes #1085
Posted by da...@apache.org.
Fixed CS. This closes #1085
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0c905223
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0c905223
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0c905223
Branch: refs/heads/master
Commit: 0c905223bbf3035f975cd4e2d0fcda5e20490b61
Parents: d7cb730
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Jul 24 13:51:15 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Jul 24 13:51:15 2016 +0200
----------------------------------------------------------------------
...AsyncEndpointRoutingSlipBeanNonBlockingTest.java | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/0c905223/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointRoutingSlipBeanNonBlockingTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointRoutingSlipBeanNonBlockingTest.java b/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointRoutingSlipBeanNonBlockingTest.java
index 7b8eab3..4cfac28 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointRoutingSlipBeanNonBlockingTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointRoutingSlipBeanNonBlockingTest.java
@@ -16,7 +16,18 @@
*/
package org.apache.camel.processor.async;
-import org.apache.camel.*;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.AsyncCallback;
+import org.apache.camel.AsyncProcessor;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.RoutingSlip;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.JndiRegistry;
import org.apache.camel.processor.SendProcessor;
@@ -24,8 +35,6 @@ import org.apache.camel.util.AsyncProcessorHelper;
import org.apache.camel.util.ServiceHelper;
import org.junit.Assert;
-import java.util.concurrent.*;
-
/**
* @version
*/
@@ -106,6 +115,7 @@ public class AsyncEndpointRoutingSlipBeanNonBlockingTest extends ContextTestSupp
}
private class MyAsyncProcessor implements AsyncProcessor {
+
@Override
public boolean process(Exchange exchange, AsyncCallback callback) {
innerCallback = callback;
[4/4] camel git commit: Fixed CS
Posted by da...@apache.org.
Fixed CS
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2d0de2bb
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2d0de2bb
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2d0de2bb
Branch: refs/heads/master
Commit: 2d0de2bbf27a71b8d7dad6284e092ba456ec5794
Parents: 9dce509
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Jul 24 13:53:31 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Jul 24 13:53:31 2016 +0200
----------------------------------------------------------------------
.../async/AsyncEndpointRoutingSlipBeanNonBlockingTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/2d0de2bb/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointRoutingSlipBeanNonBlockingTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointRoutingSlipBeanNonBlockingTest.java b/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointRoutingSlipBeanNonBlockingTest.java
index 4cfac28..57ca2f4 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointRoutingSlipBeanNonBlockingTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointRoutingSlipBeanNonBlockingTest.java
@@ -96,7 +96,7 @@ public class AsyncEndpointRoutingSlipBeanNonBlockingTest extends ContextTestSupp
private final Endpoint startEndpoint;
private final SendProcessor asyncSender;
- public ExchangeSubmitter(Endpoint startEndpoint, SendProcessor asyncSender) {
+ ExchangeSubmitter(Endpoint startEndpoint, SendProcessor asyncSender) {
this.startEndpoint = startEndpoint;
this.asyncSender = asyncSender;
}
[3/4] camel git commit: Fixed CS
Posted by da...@apache.org.
Fixed CS
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9dce5091
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9dce5091
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9dce5091
Branch: refs/heads/master
Commit: 9dce5091bc7533e294d09dfd08554f3e8f92bd2e
Parents: 0c90522
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Jul 24 13:53:17 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Jul 24 13:53:17 2016 +0200
----------------------------------------------------------------------
.../org/apache/camel/impl/DefaultAttachment.java | 4 ++--
.../java/org/apache/camel/util/AttachmentMap.java | 18 ++++++++++--------
2 files changed, 12 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/9dce5091/camel-core/src/main/java/org/apache/camel/impl/DefaultAttachment.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultAttachment.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultAttachment.java
index dbb87af..8a1ad89 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultAttachment.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultAttachment.java
@@ -29,7 +29,7 @@ import org.apache.camel.Attachment;
import org.apache.camel.util.CollectionHelper;
public class DefaultAttachment implements Attachment {
- private Map<String, Object> headers = null;
+ private Map<String, Object> headers;
private DataHandler dataHandler;
public DefaultAttachment(DataHandler dh) {
@@ -120,6 +120,6 @@ public class DefaultAttachment implements Attachment {
}
public int hashCode() {
- return (dataHandler.hashCode());
+ return dataHandler.hashCode();
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/9dce5091/camel-core/src/main/java/org/apache/camel/util/AttachmentMap.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/AttachmentMap.java b/camel-core/src/main/java/org/apache/camel/util/AttachmentMap.java
index 1f33546..b6c0a5f 100644
--- a/camel-core/src/main/java/org/apache/camel/util/AttachmentMap.java
+++ b/camel-core/src/main/java/org/apache/camel/util/AttachmentMap.java
@@ -60,7 +60,7 @@ public class AttachmentMap extends AbstractMap<String, DataHandler> {
private static class AttachmentEntrySet extends AbstractSet<Map.Entry<String, DataHandler>> {
private Set<Map.Entry<String, Attachment>> set;
- public AttachmentEntrySet(Set<Map.Entry<String, Attachment>> set) {
+ AttachmentEntrySet(Set<Map.Entry<String, Attachment>> set) {
this.set = set;
}
@@ -78,7 +78,7 @@ public class AttachmentMap extends AbstractMap<String, DataHandler> {
private static class AttachmentEntrySetIterator implements Iterator<Map.Entry<String, DataHandler>> {
private Iterator<Map.Entry<String, Attachment>> iter;
- public AttachmentEntrySetIterator(Iterator<Map.Entry<String, Attachment>> origIterator) {
+ AttachmentEntrySetIterator(Iterator<Map.Entry<String, Attachment>> origIterator) {
iter = origIterator;
}
@@ -100,7 +100,7 @@ public class AttachmentMap extends AbstractMap<String, DataHandler> {
private static class AttachmentEntry implements Map.Entry<String, DataHandler> {
private Map.Entry<String, Attachment> entry;
- public AttachmentEntry(Map.Entry<String, Attachment> backingEntry) {
+ AttachmentEntry(Map.Entry<String, Attachment> backingEntry) {
this.entry = backingEntry;
}
@@ -112,24 +112,26 @@ public class AttachmentMap extends AbstractMap<String, DataHandler> {
@Override
public DataHandler getValue() {
Attachment value = entry.getValue();
- if (value != null)
+ if (value != null) {
return value.getDataHandler();
+ }
return null;
}
@Override
public DataHandler setValue(DataHandler value) {
Attachment oldValue = entry.setValue(new DefaultAttachment(value));
- if (oldValue != null)
+ if (oldValue != null) {
return oldValue.getDataHandler();
+ }
return null;
}
- // two AttachmentEntry objects are equal if the backing entries are
- // equal
+ // two AttachmentEntry objects are equal if the backing entries are equal
public boolean equals(Object o) {
- if (o instanceof AttachmentEntry && entry.equals(((AttachmentEntry)o).entry))
+ if (o instanceof AttachmentEntry && entry.equals(((AttachmentEntry)o).entry)) {
return true;
+ }
return false;
}