You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2018/12/10 07:34:57 UTC
[camel] branch master updated (c7722f2 -> 3d017f0)
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.
from c7722f2 Upgrade Awaitility to version 3.1.5
new d80d4c2 CAMEL-12985: TransactionErrorHandler fails if UnitOfWork is null
new 36ba145 CAMEL-12985: Added a test that fails on master
new 3d017f0 CAMEL-12985 - Fixed CS
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../camel/spring/spi/TransactionErrorHandler.java | 12 ++++++---
...nterceptUsingAdviceWithSendToEndpointTest.java} | 30 ++++++++++++++++++----
2 files changed, 34 insertions(+), 8 deletions(-)
copy components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/{TransactedInterceptSendToEndpointTest.java => TransactedInterceptUsingAdviceWithSendToEndpointTest.java} (71%)
[camel] 03/03: CAMEL-12985 - Fixed CS
Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 3d017f0cf461e98b4b2344ff8d6fdb02c47f598d
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Dec 10 08:24:30 2018 +0100
CAMEL-12985 - Fixed CS
---
.../org/apache/camel/spring/spi/TransactionErrorHandler.java | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandler.java b/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandler.java
index 8177c4b..ab31814 100644
--- a/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandler.java
+++ b/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandler.java
@@ -95,7 +95,9 @@ public class TransactionErrorHandler extends RedeliveryErrorHandler {
public void process(Exchange exchange) throws Exception {
// we have to run this synchronously as Spring Transaction does *not* support
// using multiple threads to span a transaction
- if (transactionTemplate.getPropagationBehavior() != TransactionDefinition.PROPAGATION_REQUIRES_NEW && exchange.getUnitOfWork() != null && exchange.getUnitOfWork().isTransactedBy(transactionKey)) {
+ if (transactionTemplate.getPropagationBehavior() != TransactionDefinition.PROPAGATION_REQUIRES_NEW
+ && exchange.getUnitOfWork() != null
+ && exchange.getUnitOfWork().isTransactedBy(transactionKey)) {
// already transacted by this transaction template
// so lets just let the error handler process it
processByErrorHandler(exchange);
@@ -129,8 +131,9 @@ public class TransactionErrorHandler extends RedeliveryErrorHandler {
try {
// mark the beginning of this transaction boundary
- if (exchange.getUnitOfWork() != null)
+ if (exchange.getUnitOfWork() != null) {
exchange.getUnitOfWork().beginTransactedBy(transactionKey);
+ }
// do in transaction
logTransactionBegin(redelivered, ids);
@@ -145,8 +148,9 @@ public class TransactionErrorHandler extends RedeliveryErrorHandler {
logTransactionRollback(redelivered, ids, e, false);
} finally {
// mark the end of this transaction boundary
- if (exchange.getUnitOfWork() != null)
+ if (exchange.getUnitOfWork() != null) {
exchange.getUnitOfWork().endTransactedBy(transactionKey);
+ }
}
// if it was a local rollback only then remove its marker so outer transaction wont see the marker
[camel] 01/03: CAMEL-12985: TransactionErrorHandler fails if
UnitOfWork is null
Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit d80d4c2ae04c6defb3c3de5f9ff5ef12e461cb1a
Author: Jess Sightler <je...@gmail.com>
AuthorDate: Fri Dec 7 13:07:43 2018 -0500
CAMEL-12985: TransactionErrorHandler fails if UnitOfWork is null
---
.../java/org/apache/camel/spring/spi/TransactionErrorHandler.java | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandler.java b/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandler.java
index 5d3bf78..8177c4b 100644
--- a/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandler.java
+++ b/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandler.java
@@ -95,7 +95,7 @@ public class TransactionErrorHandler extends RedeliveryErrorHandler {
public void process(Exchange exchange) throws Exception {
// we have to run this synchronously as Spring Transaction does *not* support
// using multiple threads to span a transaction
- if (transactionTemplate.getPropagationBehavior() != TransactionDefinition.PROPAGATION_REQUIRES_NEW && exchange.getUnitOfWork().isTransactedBy(transactionKey)) {
+ if (transactionTemplate.getPropagationBehavior() != TransactionDefinition.PROPAGATION_REQUIRES_NEW && exchange.getUnitOfWork() != null && exchange.getUnitOfWork().isTransactedBy(transactionKey)) {
// already transacted by this transaction template
// so lets just let the error handler process it
processByErrorHandler(exchange);
@@ -129,7 +129,8 @@ public class TransactionErrorHandler extends RedeliveryErrorHandler {
try {
// mark the beginning of this transaction boundary
- exchange.getUnitOfWork().beginTransactedBy(transactionKey);
+ if (exchange.getUnitOfWork() != null)
+ exchange.getUnitOfWork().beginTransactedBy(transactionKey);
// do in transaction
logTransactionBegin(redelivered, ids);
@@ -144,7 +145,8 @@ public class TransactionErrorHandler extends RedeliveryErrorHandler {
logTransactionRollback(redelivered, ids, e, false);
} finally {
// mark the end of this transaction boundary
- exchange.getUnitOfWork().endTransactedBy(transactionKey);
+ if (exchange.getUnitOfWork() != null)
+ exchange.getUnitOfWork().endTransactedBy(transactionKey);
}
// if it was a local rollback only then remove its marker so outer transaction wont see the marker
[camel] 02/03: CAMEL-12985: Added a test that fails on master
Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 36ba1458644439ab35097f32c4a1c102fffed8fa
Author: Jess Sightler <je...@gmail.com>
AuthorDate: Fri Dec 7 19:07:18 2018 -0500
CAMEL-12985: Added a test that fails on master
---
...InterceptUsingAdviceWithSendToEndpointTest.java | 93 ++++++++++++++++++++++
1 file changed, 93 insertions(+)
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactedInterceptUsingAdviceWithSendToEndpointTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactedInterceptUsingAdviceWithSendToEndpointTest.java
new file mode 100644
index 0000000..39bbf5c
--- /dev/null
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactedInterceptUsingAdviceWithSendToEndpointTest.java
@@ -0,0 +1,93 @@
+/**
+ * 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.spring.interceptor;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.SpringRouteBuilder;
+import org.junit.Test;
+
+/**
+ * Easier transaction configuration as we do not have to setup a transaction error handler
+ */
+public class TransactedInterceptUsingAdviceWithSendToEndpointTest extends TransactionalClientDataSourceTest {
+
+ @Test
+ public void testTransactionSuccess() throws Exception {
+ MockEndpoint intercepted = getMockEndpoint("mock:intercepted");
+
+ addInterceptor("ok_route");
+
+ intercepted.expectedBodiesReceived("Hello World");
+
+ super.testTransactionSuccess();
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Test
+ public void testTransactionRollback() throws Exception {
+ MockEndpoint intercepted = getMockEndpoint("mock:intercepted");
+
+ addInterceptor("fail_route");
+
+ intercepted.expectedBodiesReceived("Tiger in Action");
+
+ super.testTransactionRollback();
+
+ assertMockEndpointsSatisfied();
+ }
+
+ private void addInterceptor(String routeId) throws Exception {
+ context.getRouteDefinition(routeId).adviceWith(context, new SpringRouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ interceptSendToEndpoint("direct:(foo|bar)")
+ .to("mock:intercepted");
+ }
+ });
+ }
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new SpringRouteBuilder() {
+ public void configure() throws Exception {
+ from("direct:okay")
+ .routeId("ok_route")
+ .transacted()
+ .enrich("direct:foo", (oldExchange, newExchange) -> {
+ return newExchange;
+ })
+ .setBody(constant("Tiger in Action")).bean("bookService")
+ .setBody(constant("Elephant in Action")).bean("bookService");
+
+ from("direct:fail")
+ .routeId("fail_route")
+ .transacted()
+ .setBody(constant("Tiger in Action")).bean("bookService")
+ .enrich("direct:bar", (oldExchange, newExchange) -> {
+ return newExchange;
+ })
+ .setBody(constant("Donkey in Action")).bean("bookService");
+
+ from("direct:foo").to("log:okay");
+
+ from("direct:bar").to("mock:fail");
+ }
+ };
+ }
+
+}
\ No newline at end of file