Re: Camel 2.14/Netty: How to add ByteArrayDecoder to ServerChannelPipeline?

2015-07-09 Thread Willem Jiang
There are quit different change between the Netty3.x and Netty4.x.
That is why we create a new camel component camel-netty4[1] for it.

So I think you can just need to change the camel-netty to camel-netty4 and use 
the scheme netty4 in your camel route.

--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.iteye.com (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem



On July 1, 2015 at 9:54:43 PM, SteveR (srichard...@vonage.com) wrote:
 Hi Willem:
  
 Actually, I'm currently using Camel 2.14 and Netty 3.x (org.jboss.netty).
 I'm wondering if there is a sensible way to migrate from netty3 to netty4
 (i.e. other than just brute-force trying it) and what it would do with
 respect to my existing pipeline factory code, etc?
  
 Here's what I currently have in my pom.xml file:
  
  
 org.apache.camel
 camel-netty
 2.14.0
  
  
  
 io.netty
 netty-all
 4.0.2.Final
 compile
  
  
  
 Thanks, Steve
  
  
  
 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Camel-2-14-Netty-How-to-add-ByteArrayDecoder-to-ServerChannelPipeline-tp5768638p5768749.html
   
 Sent from the Camel - Users mailing list archive at Nabble.com.
  



Re: Camel 2.14/Netty: How to add ByteArrayDecoder to ServerChannelPipeline?

2015-07-01 Thread SteveR
Hi Willem:

Actually, I'm currently using Camel 2.14 and Netty 3.x (org.jboss.netty). 
I'm wondering if there is a sensible way to migrate from netty3 to netty4
(i.e. other than just brute-force trying it) and what it would do with
respect to my existing pipeline factory code, etc?

Here's what I currently have in my pom.xml file:

dependency
groupIdorg.apache.camel/groupId
artifactIdcamel-netty/artifactId
version2.14.0/version
/dependency

dependency
groupIdio.netty/groupId
artifactIdnetty-all/artifactId
version4.0.2.Final/version
scopecompile/scope
/dependency


 Thanks, Steve



--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-2-14-Netty-How-to-add-ByteArrayDecoder-to-ServerChannelPipeline-tp5768638p5768749.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel 2.14/Netty: How to add ByteArrayDecoder to ServerChannelPipeline?

2015-07-01 Thread Willem.Jiang
There are quit different change between the Netty3.x and Netty4.x.
That is why we create a new camel component camel-netty4[1] for it.

So I think you can just need to change the camel-netty to camel-netty4 and
use the scheme netty4 in your camel route.



--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-2-14-Netty-How-to-add-ByteArrayDecoder-to-ServerChannelPipeline-tp5768638p5768761.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Camel 2.14/Netty: How to add ByteArrayDecoder to ServerChannelPipeline?

2015-06-29 Thread SteveR
I have a linux Java7 stand-alone application using Camel 2.14 and the
camel-netty component. I have a route that receives via netty:udp and then
attempts to mirror the received packets also via netty:udp. I'm also using
the *LengthFieldBasedFrameDecoder *to decode the UDP packets into message
frames based on a 2-byte length field within each UDP message.

The UDP messages I'm receiving contain certain characters that don't decode
in UTF-8 (e.g. 0xa1 0xb2, 0xc3 ), so I've been trying to use the
*iso-8859-1* charset. I'm thinking that what I want in my
ServerPipelineFactory subclass is the
*io.netty.handler.codec.bytes.ByteArrayDecoder*, but I'm unable to get it to
compile with the *addlast()* method.

I've been using the approach outlined  here
https://github.com/apache/camel/blob/master/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyCustomPipelineFactorySynchTest.java
 
thus far, but then I run into this compile issue with *io.netty *versus
*org.jboss.netty*.

Which leads me to believe that I'm confused wrt imports for *io.netty*
versus *org.jboss.netty*?  Below is my extended *ServerPipelineFactory
*class which I'd like to switch the StringDecoder/StringEncoder for
ByteArrayDecoder/ByteArrayEncoder.

Any help is greatly appreciated!

  Thanks, SteveR


package multiprotocollistenerrouter;

//import io.netty.handler.codec.bytes.ByteArrayDecoder;
//import io.netty.handler.codec.bytes.ByteArrayEncoder;
//import io.netty.channel.ChannelPipeline;
//import io.netty.handler.codec.LengthFieldBasedFrameDecoder;

import io.netty.util.CharsetUtil;
import org.apache.camel.component.netty.NettyConsumer;
import org.apache.camel.component.netty.ServerPipelineFactory;
import org.apache.camel.component.netty.handlers.ServerChannelHandler;
import org.jboss.netty.channel.ChannelHandler;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.Channels;
import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
import org.jboss.netty.handler.codec.string.StringDecoder;
import org.jboss.netty.handler.codec.string.StringEncoder;

//import org.jboss.netty.handler.logging.LoggingHandler;
//import org.jboss.netty.logging.InternalLogLevel;

import org.slf4j.Logger;// The org.slf4j.Logger interface is the
main user entry point of SLF4J API.
import org.slf4j.LoggerFactory; // Utility class producing Loggers for
various logging APIs, most notably for log4j.

/**
 * Consumer linked channel pipeline factory for the MCQ source provider.
 * Provides custom support for reception/parsing/processing of MCQ.
 *
 * @author steve
 *
 * @see http://camel.apache.org/netty.html
 * @see
http://opensourceknowledge.blogspot.com/2010/08/customizing-netty-endpoints-using.html#
 * @see
http://seeallhearall.blogspot.com/2012/06/netty-tutorial-part-15-on-channel.html
 * @see
https://github.com/apache/camel/blob/master/components/camel-netty/src/test/
 * 
java/org/apache/camel/component/netty/NettyCustomPipelineFactorySynchTest.java
 */
public class McqServerPipelineFactory extends ServerPipelineFactory  {
private final static Logger logger   =
LoggerFactory.getLogger(McqServerPipelineFactory.class);
private static final String NEW_LINE =
System.getProperty(line.separator);

// ---
// Stateless, singleton handler instances...re-used across connections
// ---
private static final ChannelHandler STR_ENCODER = new
StringEncoder(CharsetUtil.ISO_8859_1);
private static final ChannelHandler STR_DECODER = new
StringDecoder(CharsetUtil.ISO_8859_1);

//private static final ChannelHandler LOG_HANDLER = new
LoggingHandler(InternalLogLevel.INFO);

//private static final ByteArrayDecoder BYTES_DECODER = new
ByteArrayDecoder();
//private static final ByteArrayEncoder BYTES_ENCODER = new
ByteArrayEncoder();

private final NettyConsumer consumer;

private final int maxFrameLength;
private final int lengthFieldOffset;
private final int lengthFieldLength;
private final int lengthAdjustment;
private final int initialBytesToStrip;
private boolean   invoked;
private StringrouteId;

@Override
public ChannelPipeline getPipeline() throws Exception {  
logger.trace(getPipeline(): ENTER);

invoked = true;  
ChannelPipeline channelPipeline = Channels.pipeline();  

String theRouteId = consumer.getRoute().getId();
logger.info(getPipeline(): {}, routeId = {}, consumer.toString(),
theRouteId);

// ---
// Add logger to print incoming and outgoing data.
// This is both an upstream/downstream handler.
// ---
//String loggerName = MCQ_LOGGING_HANDLER_ + theRouteId;
//channelPipeline.addLast(loggerName, LOG_HANDLER);

//