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/01/24 12:50:33 UTC
[1/9] camel git commit: CAMEL-9527: Netty client - When channel is
inactive we should not log stacktrace if the message was received and
processed
Repository: camel
Updated Branches:
refs/heads/camel-2.15.x 1805c6b45 -> 8881b79d4
refs/heads/camel-2.16.x 335e7a819 -> f4382b6d5
refs/heads/master 34a45a4bd -> 45bd634f7
CAMEL-9527: Netty client - When channel is inactive we should not log stacktrace if the message was received and processed
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9391f007
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9391f007
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9391f007
Branch: refs/heads/master
Commit: 9391f0077ed0bfa5f7588859e91eaf342f8c45fa
Parents: 34a45a4
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Jan 24 12:15:59 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Jan 24 12:15:59 2016 +0100
----------------------------------------------------------------------
.../component/netty4/handlers/ClientChannelHandler.java | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/9391f007/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java
index 160adf4..dbb7b60 100644
--- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java
+++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java
@@ -112,7 +112,7 @@ public class ClientChannelHandler extends SimpleChannelInboundHandler<Object> {
producer.getAllChannels().remove(ctx.channel());
NettyConfiguration configuration = producer.getConfiguration();
- if (configuration.isSync() && !exceptionHandled) {
+ if (configuration.isSync() && !messageReceived && !exceptionHandled) {
// To avoid call the callback.done twice
exceptionHandled = true;
// session was closed but no message received. This could be because the remote server had an internal error
@@ -201,6 +201,13 @@ public class ClientChannelHandler extends SimpleChannelInboundHandler<Object> {
}
}
+ @Override
+ public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
+ // reset flag after we have read the complete
+ messageReceived = false;
+ super.channelReadComplete(ctx);
+ }
+
/**
* Gets the Camel {@link Message} to use as the message to be set on the current {@link Exchange} when
* we have received a reply message.
[6/9] camel git commit: CAMEL-9527: Netty client - When channel is
inactive we should not log stacktrace if the message was received and
processed
Posted by da...@apache.org.
CAMEL-9527: Netty client - When channel is inactive we should not log stacktrace if the message was received and processed
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9abbd22a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9abbd22a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9abbd22a
Branch: refs/heads/camel-2.16.x
Commit: 9abbd22a9e9b61d5148fc936e4525a64b4ee30ca
Parents: 335e7a8
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Jan 24 12:15:59 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Jan 24 12:49:42 2016 +0100
----------------------------------------------------------------------
.../component/netty4/handlers/ClientChannelHandler.java | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/9abbd22a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java
index 160adf4..dbb7b60 100644
--- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java
+++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java
@@ -112,7 +112,7 @@ public class ClientChannelHandler extends SimpleChannelInboundHandler<Object> {
producer.getAllChannels().remove(ctx.channel());
NettyConfiguration configuration = producer.getConfiguration();
- if (configuration.isSync() && !exceptionHandled) {
+ if (configuration.isSync() && !messageReceived && !exceptionHandled) {
// To avoid call the callback.done twice
exceptionHandled = true;
// session was closed but no message received. This could be because the remote server had an internal error
@@ -201,6 +201,13 @@ public class ClientChannelHandler extends SimpleChannelInboundHandler<Object> {
}
}
+ @Override
+ public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
+ // reset flag after we have read the complete
+ messageReceived = false;
+ super.channelReadComplete(ctx);
+ }
+
/**
* Gets the Camel {@link Message} to use as the message to be set on the current {@link Exchange} when
* we have received a reply message.
[5/9] camel git commit: CAMEL-9527: camel netty client/producer
should graceful handle channel being closed/inactive without causing an
exception after the exchange is done.
Posted by da...@apache.org.
CAMEL-9527: camel netty client/producer should graceful handle channel being closed/inactive without causing an exception after the exchange is done.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/45bd634f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/45bd634f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/45bd634f
Branch: refs/heads/master
Commit: 45bd634f7e0db844b667480e657b103d7264d5e6
Parents: 1e5e174
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Jan 24 12:49:09 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Jan 24 12:49:09 2016 +0100
----------------------------------------------------------------------
.../camel/component/netty/handlers/ClientChannelHandler.java | 7 ++++++-
.../camel/component/netty4/handlers/ClientChannelHandler.java | 6 +++++-
2 files changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/45bd634f/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java b/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
index 8988ad5..638d8eb 100644
--- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
+++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
@@ -114,7 +114,11 @@ public class ClientChannelHandler extends SimpleChannelUpstreamHandler {
// to keep track of open sockets
producer.getAllChannels().remove(ctx.getChannel());
- if (producer.getConfiguration().isSync() && !messageReceived && !exceptionHandled) {
+ // this channel is maybe closing graceful and the exchange is already done
+ // and if so we should not trigger an exception
+ boolean doneUoW = exchange.getUnitOfWork() == null;
+
+ if (producer.getConfiguration().isSync() && !doneUoW && !messageReceived && !exceptionHandled) {
// To avoid call the callback.done twice
exceptionHandled = true;
// session was closed but no message received. This could be because the remote server had an internal error
@@ -126,6 +130,7 @@ public class ClientChannelHandler extends SimpleChannelUpstreamHandler {
// signal callback
callback.done(false);
}
+
// make sure the event can be processed by other handlers
super.channelClosed(ctx, e);
}
http://git-wip-us.apache.org/repos/asf/camel/blob/45bd634f/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java
index dbb7b60..ed4d695 100644
--- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java
+++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java
@@ -111,8 +111,12 @@ public class ClientChannelHandler extends SimpleChannelInboundHandler<Object> {
// to keep track of open sockets
producer.getAllChannels().remove(ctx.channel());
+ // this channel is maybe closing graceful and the exchange is already done
+ // and if so we should not trigger an exception
+ boolean doneUoW = exchange.getUnitOfWork() == null;
+
NettyConfiguration configuration = producer.getConfiguration();
- if (configuration.isSync() && !messageReceived && !exceptionHandled) {
+ if (configuration.isSync() && !doneUoW && !messageReceived && !exceptionHandled) {
// To avoid call the callback.done twice
exceptionHandled = true;
// session was closed but no message received. This could be because the remote server had an internal error
[9/9] camel git commit: CAMEL-9527: camel netty client/producer
should graceful handle channel being closed/inactive without causing an
exception after the exchange is done.
Posted by da...@apache.org.
CAMEL-9527: camel netty client/producer should graceful handle channel being closed/inactive without causing an exception after the exchange is done.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8881b79d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8881b79d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8881b79d
Branch: refs/heads/camel-2.15.x
Commit: 8881b79d4122b87d47962110fbd44607530b460c
Parents: f0a65e6
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Jan 24 12:49:09 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Jan 24 12:50:24 2016 +0100
----------------------------------------------------------------------
.../camel/component/netty/handlers/ClientChannelHandler.java | 7 ++++++-
.../camel/component/netty4/handlers/ClientChannelHandler.java | 6 +++++-
2 files changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/8881b79d/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java b/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
index 475e14b..9c370e2 100644
--- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
+++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
@@ -109,7 +109,11 @@ public class ClientChannelHandler extends SimpleChannelUpstreamHandler {
// to keep track of open sockets
producer.getAllChannels().remove(ctx.getChannel());
- if (producer.getConfiguration().isSync() && !messageReceived && !exceptionHandled) {
+ // this channel is maybe closing graceful and the exchange is already done
+ // and if so we should not trigger an exception
+ boolean doneUoW = exchange.getUnitOfWork() == null;
+
+ if (producer.getConfiguration().isSync() && !doneUoW && !messageReceived && !exceptionHandled) {
// To avoid call the callback.done twice
exceptionHandled = true;
// session was closed but no message received. This could be because the remote server had an internal error
@@ -121,6 +125,7 @@ public class ClientChannelHandler extends SimpleChannelUpstreamHandler {
// signal callback
callback.done(false);
}
+
// make sure the event can be processed by other handlers
super.channelClosed(ctx, e);
}
http://git-wip-us.apache.org/repos/asf/camel/blob/8881b79d/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java
index 937d2d0..25530ef 100644
--- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java
+++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java
@@ -106,8 +106,12 @@ public class ClientChannelHandler extends SimpleChannelInboundHandler<Object> {
// to keep track of open sockets
producer.getAllChannels().remove(ctx.channel());
+ // this channel is maybe closing graceful and the exchange is already done
+ // and if so we should not trigger an exception
+ boolean doneUoW = exchange.getUnitOfWork() == null;
+
NettyConfiguration configuration = producer.getConfiguration();
- if (configuration.isSync() && !messageReceived && !exceptionHandled) {
+ if (configuration.isSync() && !doneUoW && !messageReceived && !exceptionHandled) {
// To avoid call the callback.done twice
exceptionHandled = true;
// session was closed but no message received. This could be because the remote server had an internal error
[7/9] camel git commit: CAMEL-9527: camel netty client/producer
should graceful handle channel being closed/inactive without causing an
exception after the exchange is done.
Posted by da...@apache.org.
CAMEL-9527: camel netty client/producer should graceful handle channel being closed/inactive without causing an exception after the exchange is done.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f4382b6d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f4382b6d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f4382b6d
Branch: refs/heads/camel-2.16.x
Commit: f4382b6d51016b3fc9ca9fb2a878ec1d14bde37b
Parents: 9abbd22
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Jan 24 12:49:09 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Jan 24 12:49:58 2016 +0100
----------------------------------------------------------------------
.../camel/component/netty/handlers/ClientChannelHandler.java | 7 ++++++-
.../camel/component/netty4/handlers/ClientChannelHandler.java | 6 +++++-
2 files changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/f4382b6d/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java b/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
index 8988ad5..638d8eb 100644
--- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
+++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
@@ -114,7 +114,11 @@ public class ClientChannelHandler extends SimpleChannelUpstreamHandler {
// to keep track of open sockets
producer.getAllChannels().remove(ctx.getChannel());
- if (producer.getConfiguration().isSync() && !messageReceived && !exceptionHandled) {
+ // this channel is maybe closing graceful and the exchange is already done
+ // and if so we should not trigger an exception
+ boolean doneUoW = exchange.getUnitOfWork() == null;
+
+ if (producer.getConfiguration().isSync() && !doneUoW && !messageReceived && !exceptionHandled) {
// To avoid call the callback.done twice
exceptionHandled = true;
// session was closed but no message received. This could be because the remote server had an internal error
@@ -126,6 +130,7 @@ public class ClientChannelHandler extends SimpleChannelUpstreamHandler {
// signal callback
callback.done(false);
}
+
// make sure the event can be processed by other handlers
super.channelClosed(ctx, e);
}
http://git-wip-us.apache.org/repos/asf/camel/blob/f4382b6d/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java
index dbb7b60..ed4d695 100644
--- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java
+++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java
@@ -111,8 +111,12 @@ public class ClientChannelHandler extends SimpleChannelInboundHandler<Object> {
// to keep track of open sockets
producer.getAllChannels().remove(ctx.channel());
+ // this channel is maybe closing graceful and the exchange is already done
+ // and if so we should not trigger an exception
+ boolean doneUoW = exchange.getUnitOfWork() == null;
+
NettyConfiguration configuration = producer.getConfiguration();
- if (configuration.isSync() && !messageReceived && !exceptionHandled) {
+ if (configuration.isSync() && !doneUoW && !messageReceived && !exceptionHandled) {
// To avoid call the callback.done twice
exceptionHandled = true;
// session was closed but no message received. This could be because the remote server had an internal error
[4/9] camel git commit: Added unit test
Posted by da...@apache.org.
Added unit test
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/1e5e1746
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1e5e1746
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1e5e1746
Branch: refs/heads/master
Commit: 1e5e174645955c35486312e60e9432a2f2835cbd
Parents: d53e31d
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Jan 24 12:45:25 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Jan 24 12:45:25 2016 +0100
----------------------------------------------------------------------
.../camel/component/hl7/HL7MLLPNettyRouteToTest.java | 12 ++----------
.../camel-hl7/src/test/resources/log4j.properties | 2 +-
2 files changed, 3 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/1e5e1746/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPNettyRouteToTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPNettyRouteToTest.java b/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPNettyRouteToTest.java
index 642fdee..dca6eb7 100644
--- a/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPNettyRouteToTest.java
+++ b/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPNettyRouteToTest.java
@@ -55,18 +55,10 @@ public class HL7MLLPNettyRouteToTest extends HL7TestSupport {
public void configure() throws Exception {
from("direct:start")
.to("netty4:tcp://127.0.0.1:" + getPort() + "?sync=true&decoder=#hl7decoder&encoder=#hl7encoder")
- .process(new Processor() {
- @Override
- public void process(Exchange exchange) throws Exception {
- String body = exchange.getIn().getBody(String.class);
- System.out.println(body);
- log.info(body);
- }
- })
- .log("I was here ${body}")
+ // because HL7 message contains a bunch of control chars then the logger do not log all of the data
+ .log("HL7 message: ${body}")
.to("mock:result");
-
from("netty4:tcp://127.0.0.1:" + getPort() + "?sync=true&decoder=#hl7decoder&encoder=#hl7encoder")
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
http://git-wip-us.apache.org/repos/asf/camel/blob/1e5e1746/components/camel-hl7/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/camel-hl7/src/test/resources/log4j.properties b/components/camel-hl7/src/test/resources/log4j.properties
index e7a6576..a04cbb0 100644
--- a/components/camel-hl7/src/test/resources/log4j.properties
+++ b/components/camel-hl7/src/test/resources/log4j.properties
@@ -18,7 +18,7 @@
#
# The logging properties used for testing.
#
-log4j.rootLogger=INFO, out
+log4j.rootLogger=INFO, file
# uncomment the following to enable camel debugging
#log4j.logger.org.apache.camel.component.hl7=DEBUG
[2/9] camel git commit: Added unit test
Posted by da...@apache.org.
Added unit test
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0bb82e11
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0bb82e11
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0bb82e11
Branch: refs/heads/master
Commit: 0bb82e11b40e794163d56e2b97ea21adf9b69f1f
Parents: 9391f00
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Jan 24 12:16:31 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Jan 24 12:16:31 2016 +0100
----------------------------------------------------------------------
.../component/hl7/HL7MLLPNettyRouteToTest.java | 133 +++++++++++++++++++
.../src/test/resources/log4j.properties | 21 +--
2 files changed, 144 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/0bb82e11/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPNettyRouteToTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPNettyRouteToTest.java b/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPNettyRouteToTest.java
new file mode 100644
index 0000000..642fdee
--- /dev/null
+++ b/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPNettyRouteToTest.java
@@ -0,0 +1,133 @@
+/**
+ * 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.component.hl7;
+
+import ca.uhn.hl7v2.model.Message;
+import ca.uhn.hl7v2.model.v24.message.ADR_A19;
+import ca.uhn.hl7v2.model.v24.segment.MSA;
+import ca.uhn.hl7v2.model.v24.segment.MSH;
+import ca.uhn.hl7v2.model.v24.segment.QRD;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.JndiRegistry;
+import org.junit.Test;
+
+/**
+ * Unit test for the HL7MLLPNetty Codec.
+ */
+public class HL7MLLPNettyRouteToTest extends HL7TestSupport {
+
+ protected JndiRegistry createRegistry() throws Exception {
+ JndiRegistry jndi = super.createRegistry();
+
+ // START SNIPPET: e1
+ HL7MLLPNettyDecoderFactory decoder = new HL7MLLPNettyDecoderFactory();
+ decoder.setCharset("iso-8859-1");
+ decoder.setConvertLFtoCR(true);
+ jndi.bind("hl7decoder", decoder);
+
+ HL7MLLPNettyEncoderFactory encoder = new HL7MLLPNettyEncoderFactory();
+ decoder.setCharset("iso-8859-1");
+ decoder.setConvertLFtoCR(true);
+ jndi.bind("hl7encoder", encoder);
+ // END SNIPPET: e1
+
+ return jndi;
+ }
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() throws Exception {
+ from("direct:start")
+ .to("netty4:tcp://127.0.0.1:" + getPort() + "?sync=true&decoder=#hl7decoder&encoder=#hl7encoder")
+ .process(new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ String body = exchange.getIn().getBody(String.class);
+ System.out.println(body);
+ log.info(body);
+ }
+ })
+ .log("I was here ${body}")
+ .to("mock:result");
+
+
+ from("netty4:tcp://127.0.0.1:" + getPort() + "?sync=true&decoder=#hl7decoder&encoder=#hl7encoder")
+ .process(new Processor() {
+ public void process(Exchange exchange) throws Exception {
+ Message input = exchange.getIn().getBody(Message.class);
+
+ assertEquals("2.4", input.getVersion());
+ QRD qrd = (QRD)input.get("QRD");
+ assertEquals("0101701234", qrd.getWhoSubjectFilter(0).getIDNumber().getValue());
+
+ Message response = createHL7AsMessage();
+ exchange.getOut().setBody(response);
+ }
+ });
+ }
+ };
+ }
+
+ @Test
+ public void testSendHL7Message() throws Exception {
+ getMockEndpoint("mock:result").expectedMessageCount(1);
+
+ // START SNIPPET: e2
+ String line1 = "MSH|^~\\&|MYSENDER|MYRECEIVER|MYAPPLICATION||200612211200||QRY^A19|1234|P|2.4";
+ String line2 = "QRD|200612211200|R|I|GetPatient|||1^RD|0101701234|DEM||";
+
+ StringBuilder in = new StringBuilder();
+ in.append(line1);
+ in.append("\n");
+ in.append(line2);
+
+ String out = template.requestBody("direct:start", in.toString(), String.class);
+ // END SNIPPET: e2
+
+ String[] lines = out.split("\r");
+ assertEquals("MSH|^~\\&|MYSENDER||||200701011539||ADR^A19^ADR_A19|456|P|2.4", lines[0]);
+ assertEquals("MSA|AA|123", lines[1]);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ // START SNIPPET: e3
+ private static Message createHL7AsMessage() throws Exception {
+ ADR_A19 adr = new ADR_A19();
+ adr.initQuickstart("ADR", "A19", "P");
+
+ // Populate the MSH Segment
+ MSH mshSegment = adr.getMSH();
+ mshSegment.getDateTimeOfMessage().getTimeOfAnEvent().setValue("200701011539");
+ mshSegment.getSendingApplication().getNamespaceID().setValue("MYSENDER");
+ mshSegment.getMessageControlID().setValue("456");
+
+ // Populate the PID Segment
+ MSA msa = adr.getMSA();
+ msa.getAcknowledgementCode().setValue("AA");
+ msa.getMessageControlID().setValue("123");
+
+ QRD qrd = adr.getQRD();
+ qrd.getQueryDateTime().getTimeOfAnEvent().setValue("20080805120000");
+
+ return adr;
+ }
+ // END SNIPPET: e3
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/0bb82e11/components/camel-hl7/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/camel-hl7/src/test/resources/log4j.properties b/components/camel-hl7/src/test/resources/log4j.properties
index 5d0c9a9..e7a6576 100644
--- a/components/camel-hl7/src/test/resources/log4j.properties
+++ b/components/camel-hl7/src/test/resources/log4j.properties
@@ -1,4 +1,4 @@
-## ---------------------------------------------------------------------------
+## ------------------------------------------------------------------------
## 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.
@@ -13,23 +13,24 @@
## 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.
-## ---------------------------------------------------------------------------
+## ------------------------------------------------------------------------
#
-# The logging properties used during tests..
+# The logging properties used for testing.
#
-log4j.rootLogger=INFO, file
+log4j.rootLogger=INFO, out
+
+# uncomment the following to enable camel debugging
+#log4j.logger.org.apache.camel.component.hl7=DEBUG
# CONSOLE appender not used by default
-log4j.appender.console=org.apache.log4j.ConsoleAppender
-log4j.appender.console.layout=org.apache.log4j.PatternLayout
-log4j.appender.console.layout.ConversionPattern=%d %-5p %c{1} - %m %n
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
# File appender
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d %-5p %c{1} - %m %n
log4j.appender.file.file=target/camel-hl7-test.log
-
-# debug loging for Camel
-log4j.logger.org.apache.camel.component.hl7=DEBUG
[3/9] camel git commit: CamelLogger should only call log with marker
if marker is not null.
Posted by da...@apache.org.
CamelLogger should only call log with marker if marker is not null.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d53e31d1
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d53e31d1
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d53e31d1
Branch: refs/heads/master
Commit: d53e31d1b2842acaf00d09b59495de86f3fc1cdc
Parents: 0bb82e1
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Jan 24 12:25:34 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Jan 24 12:25:34 2016 +0100
----------------------------------------------------------------------
.../src/main/java/org/apache/camel/util/CamelLogger.java | 10 ++++++++++
1 file changed, 10 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/d53e31d1/camel-core/src/main/java/org/apache/camel/util/CamelLogger.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/CamelLogger.java b/camel-core/src/main/java/org/apache/camel/util/CamelLogger.java
index 65b9683..602e062 100644
--- a/camel-core/src/main/java/org/apache/camel/util/CamelLogger.java
+++ b/camel-core/src/main/java/org/apache/camel/util/CamelLogger.java
@@ -169,6 +169,11 @@ public class CamelLogger {
}
public static void log(Logger log, LoggingLevel level, Marker marker, String message) {
+ if (marker == null) {
+ log(log, level, message);
+ }
+
+ // marker must be provided
switch (level) {
case DEBUG:
log.debug(marker, message);
@@ -211,6 +216,11 @@ public class CamelLogger {
}
public static void log(Logger log, LoggingLevel level, Marker marker, String message, Throwable th) {
+ if (marker == null) {
+ log(log, level, message, th);
+ }
+
+ // marker must be provided
switch (level) {
case DEBUG:
log.debug(marker, message, th);
[8/9] camel git commit: CAMEL-9527: Netty client - When channel is
inactive we should not log stacktrace if the message was received and
processed
Posted by da...@apache.org.
CAMEL-9527: Netty client - When channel is inactive we should not log stacktrace if the message was received and processed
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f0a65e6a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f0a65e6a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f0a65e6a
Branch: refs/heads/camel-2.15.x
Commit: f0a65e6a35a9fed4cca32787f2713d7a419b27ff
Parents: 1805c6b
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Jan 24 12:15:59 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Jan 24 12:50:17 2016 +0100
----------------------------------------------------------------------
.../component/netty4/handlers/ClientChannelHandler.java | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/f0a65e6a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java
index 9e51053..937d2d0 100644
--- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java
+++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/handlers/ClientChannelHandler.java
@@ -107,7 +107,7 @@ public class ClientChannelHandler extends SimpleChannelInboundHandler<Object> {
producer.getAllChannels().remove(ctx.channel());
NettyConfiguration configuration = producer.getConfiguration();
- if (configuration.isSync() && !exceptionHandled) {
+ if (configuration.isSync() && !messageReceived && !exceptionHandled) {
// To avoid call the callback.done twice
exceptionHandled = true;
// session was closed but no message received. This could be because the remote server had an internal error
@@ -197,6 +197,13 @@ public class ClientChannelHandler extends SimpleChannelInboundHandler<Object> {
}
}
+ @Override
+ public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
+ // reset flag after we have read the complete
+ messageReceived = false;
+ super.channelReadComplete(ctx);
+ }
+
/**
* Gets the Camel {@link Message} to use as the message to be set on the current {@link Exchange} when
* we have received a reply message.