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 2021/04/16 05:26:13 UTC
[camel] 02/02: CAMEL-16366: camel-netty and camel-netty-http -
Support Exchange pooling.
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 c9c4c74e143ca3e12d2403d0e41d7710aecfd121
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Apr 16 07:25:33 2021 +0200
CAMEL-16366: camel-netty and camel-netty-http - Support Exchange pooling.
---
.../component/netty/http/handlers/HttpServerChannelHandler.java | 5 +----
.../apache/camel/component/netty/handlers/ServerChannelHandler.java | 4 +++-
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java
index bd4bdf3..dea2054 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java
@@ -323,10 +323,8 @@ public class HttpServerChannelHandler extends ServerChannelHandler {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
-
// only close if we are still allowed to run
if (consumer.isRunAllowed()) {
-
if (cause instanceof ClosedChannelException) {
LOG.debug("Channel already closed. Ignoring this exception.");
} else {
@@ -344,8 +342,7 @@ public class HttpServerChannelHandler extends ServerChannelHandler {
@Override
protected Exchange createExchange(ChannelHandlerContext ctx, Object message) throws Exception {
- // must be prototype scoped (not pooled) so we create the exchange via endpoint
- Exchange exchange = consumer.getEndpoint().createExchange();
+ Exchange exchange = this.consumer.createExchange(false);
// create a new IN message as we cannot reuse with netty
Message in;
diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ServerChannelHandler.java b/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ServerChannelHandler.java
index a6f5909..55d3a20 100644
--- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ServerChannelHandler.java
+++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ServerChannelHandler.java
@@ -115,7 +115,7 @@ public class ServerChannelHandler extends SimpleChannelInboundHandler<Object> {
protected Exchange createExchange(ChannelHandlerContext ctx, Object message) throws Exception {
// must be prototype scoped (not pooled) so we create the exchange via endpoint
- Exchange exchange = consumer.getEndpoint().createExchange();
+ Exchange exchange = consumer.createExchange(false);
consumer.getEndpoint().updateMessageHeader(exchange.getIn(), ctx);
NettyPayloadHelper.setIn(exchange, message);
return exchange;
@@ -142,6 +142,7 @@ public class ServerChannelHandler extends SimpleChannelInboundHandler<Object> {
consumer.getExceptionHandler().handleException(e);
} finally {
consumer.doneUoW(exchange);
+ consumer.releaseExchange(exchange, false);
}
}
@@ -156,6 +157,7 @@ public class ServerChannelHandler extends SimpleChannelInboundHandler<Object> {
consumer.getExceptionHandler().handleException(e);
} finally {
consumer.doneUoW(exchange);
+ consumer.releaseExchange(exchange, false);
}
});
}