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 2020/02/02 20:42:25 UTC
[camel] 02/03: CAMEL-14354: camel-core - Optimize to reduce object
allocations for lambda in error handling (critical code path) which gains >
10%
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 2a79dccda2ce54ea5a5dff0b7a55e8d9430157bd
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Feb 2 20:00:09 2020 +0100
CAMEL-14354: camel-core - Optimize to reduce object allocations for lambda in error handling (critical code path) which gains > 10%
---
.../errorhandler/RedeliveryErrorHandler.java | 27 ++++++++++++----------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/core/camel-base/src/main/java/org/apache/camel/processor/errorhandler/RedeliveryErrorHandler.java b/core/camel-base/src/main/java/org/apache/camel/processor/errorhandler/RedeliveryErrorHandler.java
index bd1bf11..ea0a025 100644
--- a/core/camel-base/src/main/java/org/apache/camel/processor/errorhandler/RedeliveryErrorHandler.java
+++ b/core/camel-base/src/main/java/org/apache/camel/processor/errorhandler/RedeliveryErrorHandler.java
@@ -346,7 +346,7 @@ public abstract class RedeliveryErrorHandler extends ErrorHandlerSupport impleme
/**
* Simple task to perform calling the processor with no redelivery support
*/
- protected class SimpleTask implements Runnable {
+ protected class SimpleTask implements Runnable, AsyncCallback {
private final ExtendedExchange exchange;
private final AsyncCallback callback;
@@ -360,6 +360,17 @@ public abstract class RedeliveryErrorHandler extends ErrorHandlerSupport impleme
return "SimpleTask";
}
+ @Override
+ public void done(boolean doneSync) {
+ // only continue routing with the original callback
+ if (isDone(exchange)) {
+ reactiveExecutor.schedule(callback);
+ } else {
+ // error occurred so loop back around and call ourselves
+ reactiveExecutor.schedule(this);
+ }
+ }
+
/**
* Processing logic.
*/
@@ -381,19 +392,11 @@ public abstract class RedeliveryErrorHandler extends ErrorHandlerSupport impleme
onExceptionOccurred();
prepareExchangeAfterFailure(exchange);
- // we do not support redelivery so continue callback
+ // we do not support redelivery so continue routing with the original callback
reactiveExecutor.schedule(callback);
} else {
- // Simple delivery
- outputAsync.process(exchange, doneSync -> {
- // only continue with callback if we are done
- if (isDone(exchange)) {
- reactiveExecutor.schedule(callback);
- } else {
- // error occurred so loop back around and call ourselves
- reactiveExecutor.schedule(this);
- }
- });
+ // optimize to call done on ourselves
+ outputAsync.process(exchange, this);
}
}