This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch exchange-factory
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/exchange-factory by this push:
new 7f67978 CAMEL-16222: PooledExchangeFactory experiment
7f67978 is described below
commit 7f679785ef1a2aae3ac56038eedbe58d1d652061
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Feb 19 14:41:44 2021 +0100
CAMEL-16222: PooledExchangeFactory experiment
---
.../java/org/apache/camel/impl/engine/PooledExchangeFactory.java | 8 ++++++++
.../src/main/java/org/apache/camel/support/DefaultExchange.java | 6 ++----
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PooledExchangeFactory.java
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PooledExchangeFactory.java
index 6f44fb1..5e4b285 100644
---
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PooledExchangeFactory.java
+++
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PooledExchangeFactory.java
@@ -43,6 +43,8 @@ import org.slf4j.LoggerFactory;
public class PooledExchangeFactory extends ServiceSupport
implements ExchangeFactory, CamelContextAware, StaticService,
NonManagedService {
+ // TODO: optimize onDone lambdas as they will be created per instance, and
we can use static linked
+
private static final Logger LOG =
LoggerFactory.getLogger(PooledExchangeFactory.class);
private final Consumer consumer;
@@ -101,6 +103,9 @@ public class PooledExchangeFactory extends ServiceSupport
if (autoRelease) {
// the consumer will either always be in auto release mode or
not, so its safe to initialize the task only once when the exchange is created
answer.onDone(this::release);
+ } else {
+ // we need to signal true
+ answer.onDone(e -> true);
}
return answer;
} else {
@@ -126,6 +131,9 @@ public class PooledExchangeFactory extends ServiceSupport
if (autoRelease) {
// the consumer will either always be in auto release mode or
not, so its safe to initialize the task only once when the exchange is created
answer.onDone(this::release);
+ } else {
+ // we need to signal true
+ answer.onDone(e -> true);
}
return answer;
} else {
diff --git
a/core/camel-support/src/main/java/org/apache/camel/support/DefaultExchange.java
b/core/camel-support/src/main/java/org/apache/camel/support/DefaultExchange.java
index 1ba720a..ae08318 100644
---
a/core/camel-support/src/main/java/org/apache/camel/support/DefaultExchange.java
+++
b/core/camel-support/src/main/java/org/apache/camel/support/DefaultExchange.java
@@ -131,7 +131,7 @@ public final class DefaultExchange implements
ExtendedExchange {
public void done() {
// only need to do this if there is an onDone task
// and use created flag to avoid doing done more than once
- if (created > 0) {
+ if (created > 0 && onDone != null) {
this.created = 0; // by setting to 0 we also flag that this
exchange is done and needs to be reset to use again
this.properties.clear();
this.exchangeId = null;
@@ -162,9 +162,7 @@ public final class DefaultExchange implements
ExtendedExchange {
this.redeliveryExhausted = false;
this.errorHandlerHandled = null;
- if (onDone != null) {
- onDone.apply(this);
- }
+ onDone.apply(this);
}
}