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 2012/10/06 15:39:33 UTC
svn commit: r1395054 - in /camel/branches/camel-2.9.x: ./
components/camel-netty/src/main/java/org/apache/camel/component/netty/
components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/
Author: davsclaus
Date: Sat Oct 6 13:39:32 2012
New Revision: 1395054
URL: http://svn.apache.org/viewvc?rev=1395054&view=rev
Log:
Polished and use netty helper to write to channel.
Modified:
camel/branches/camel-2.9.x/ (props changed)
camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyHelper.java
camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java
camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ServerChannelHandler.java
Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
Merged /camel/trunk:r1394577
Merged /camel/branches/camel-2.10.x:r1395050
Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyHelper.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyHelper.java?rev=1395054&r1=1395053&r2=1395054&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyHelper.java (original)
+++ camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyHelper.java Sat Oct 6 13:39:32 2012
@@ -86,8 +86,14 @@ public final class NettyHelper {
// the write operation is asynchronous. Use future to wait until the session has been written
ChannelFuture future;
if (remoteAddress != null) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Writing to channel: {} remote address: {} with body: {}", new Object[]{channel, remoteAddress, body});
+ }
future = channel.write(body, remoteAddress);
} else {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Writing to channel: {} with body: {}", new Object[]{channel, body});
+ }
future = channel.write(body);
}
Modified: camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java?rev=1395054&r1=1395053&r2=1395054&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java (original)
+++ camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java Sat Oct 6 13:39:32 2012
@@ -186,15 +186,10 @@ public class NettyProducer extends Defau
return true;
}
- // log what we are writing
- LOG.debug("Writing body: {}", body);
- // write the body asynchronously
- ChannelFuture future = channel.write(body);
-
- // add listener which handles the operation
- future.addListener(new ChannelFutureListener() {
+ // write body
+ NettyHelper.writeBodyAsync(channel, null, body, exchange, new ChannelFutureListener() {
public void operationComplete(ChannelFuture channelFuture) throws Exception {
- LOG.debug("Operation complete {}", channelFuture);
+ LOG.trace("Operation complete {}", channelFuture);
if (!channelFuture.isSuccess()) {
// no success the set the caused exception and signal callback and break
exchange.setException(channelFuture.getCause());
@@ -219,8 +214,8 @@ public class NettyProducer extends Defau
disconnect = close;
}
if (disconnect) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Closing channel when complete at address: {}", getEndpoint().getConfiguration().getAddress());
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Closing channel when complete at address: {}", getEndpoint().getConfiguration().getAddress());
}
NettyHelper.close(channel);
}
Modified: camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java?rev=1395054&r1=1395053&r2=1395054&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java (original)
+++ camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java Sat Oct 6 13:39:32 2012
@@ -117,7 +117,9 @@ public class ClientChannelHandler extend
AsyncCallback callback = getAsyncCallback(ctx);
Object body = messageEvent.getMessage();
- LOG.debug("Message received: {}", body);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Receiving from channel: {} body: {}", new Object[]{messageEvent.getChannel(), body});
+ }
// if textline enabled then covert to a String which must be used for textline
if (producer.getConfiguration().isTextline()) {
@@ -152,8 +154,8 @@ public class ClientChannelHandler extend
disconnect = close;
}
if (disconnect) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Closing channel when complete at address: {}", producer.getConfiguration().getAddress());
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Closing channel when complete at address: {}", producer.getConfiguration().getAddress());
}
NettyHelper.close(ctx.getChannel());
}
Modified: camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ServerChannelHandler.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ServerChannelHandler.java?rev=1395054&r1=1395053&r2=1395054&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ServerChannelHandler.java (original)
+++ camel/branches/camel-2.9.x/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ServerChannelHandler.java Sat Oct 6 13:39:32 2012
@@ -53,14 +53,18 @@ public class ServerChannelHandler extend
@Override
public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
- LOG.trace("Channel open: {}", e.getChannel());
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Channel open: {}", e.getChannel());
+ }
// to keep track of open sockets
consumer.getAllChannels().add(e.getChannel());
}
@Override
public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
- LOG.trace("Channel closed: {}", e.getChannel());
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Channel closed: {}", e.getChannel());
+ }
}
@Override
@@ -77,7 +81,9 @@ public class ServerChannelHandler extend
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent messageEvent) throws Exception {
Object in = messageEvent.getMessage();
- LOG.debug("Incoming message: {}", in);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Receiving from channel: {} body: {}", new Object[]{messageEvent.getChannel(), in});
+ }
// create Exchange and let the consumer process it
Exchange exchange = consumer.getEndpoint().createExchange(ctx, messageEvent);
@@ -124,8 +130,8 @@ public class ServerChannelHandler extend
if (consumer.getConfiguration().isDisconnectOnNoReply()) {
// must close session if no data to write otherwise client will never receive a response
// and wait forever (if not timing out)
- if (LOG.isDebugEnabled()) {
- LOG.debug("Closing channel as no payload to send as reply at address: {}", messageEvent.getRemoteAddress());
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Closing channel as no payload to send as reply at address: {}", messageEvent.getRemoteAddress());
}
NettyHelper.close(messageEvent.getChannel());
}
@@ -136,7 +142,6 @@ public class ServerChannelHandler extend
}
// we got a body to write
- LOG.debug("Writing body: {}", body);
ChannelFutureListener listener = new ResponseFutureListener(exchange, messageEvent.getRemoteAddress());
if (consumer.getConfiguration().isTcp()) {
NettyHelper.writeBodyAsync(messageEvent.getChannel(), null, body, exchange, listener);
@@ -182,8 +187,8 @@ public class ServerChannelHandler extend
disconnect = close;
}
if (disconnect) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Closing channel when complete at address: {}", remoteAddress);
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Closing channel when complete at address: {}", remoteAddress);
}
NettyHelper.close(future.getChannel());
}