Hi,
I've been working on proxy protocol support for Camel Netty component,
perhaps that is relevant for your use case also, take a look at the
definition in this unit test:

https://github.com/apache/camel/blob/1276d434ab68eb2e50fc942de1c1297f71d0f16a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/ProxyProtocolTest.java#L65

There's a bit of documentation here:

https://github.com/apache/camel/blob/master/components/camel-netty4-http/src/main/docs/netty4-http-component.adoc#implementing-a-reverse-proxy

zoran

On Sun, Jun 9, 2019 at 6:54 AM canukit <[email protected]> wrote:
>
> Hello
>
> I am new to netty and camel and am trying to create a proxy using apache 
> camel and its netty4 component.
>
> I want to receive data from a server, forward that data to a seda queue and 
> then send that data from the seda queue to another server that requires a 
> handshake be performed first which I will be trying to do within a decoder.
>
> The issue I'm having right now is that when I try to add a custom encoder / 
> decoder I never receive the data from the seda queue in the channelRead 
> method when extending a ChannelInboundHandlerAdapter
>
> So far I have tried without a decoder/encoder and the data is forwarded 
> through the routes and received at the destination server but not when a 
> decoder is added to the destination server netty component.  The handshake is 
> not added yet as I am trying to get the flow of data correct.
>
> Versions:
> compile group: 'org.apache.camel', name: 'camel-core', version: '2.24.0'
> compile group: 'org.apache.camel', name: 'camel-netty4', version: '2.24.0'
>
> Fedora 29 - openjdk version "11.0.3" 2019-04-16
>
> Classes
>
> NettyCamelPractice.java
>
> public class NettyCamelPractice {
>
>     public static void main(String args[]) throws Exception {
>         Main camelMain = new Main();
>
>         try {
>             camelMain.getOrCreateCamelContext();
>             camelMain.bind("testDecoderHandler", new TestDecoderHandler());
>             camelMain.addRouteBuilder(new NettyCamelPracticeRouteBuilder());
>
>             camelMain.run();
>         } finally {
>             camelMain.shutdown();
>         }
>     }
> }
>
> NettyCamelPracticeRouteBuilder.java
>
> public class NettyCamelPracticeRouteBuilder extends RouteBuilder {
>
>     @Override
>     public void configure() throws Exception {
>         testRoute();
>         sedaQueue();
>     }
>
>     public void testRoute() {
>         System.out.println("here");
>         from("netty4:tcp://127.0.0.1:1234?clientMode=true&textline=true")
>                 .to("seda:tmp_queue");
>
>     }
>
>     public void sedaQueue() {
>         from("seda:tmp_queue")
>                 .log(LoggingLevel.INFO, "Got the message - ${body}")
>                 
> .to("netty4:tcp://127.0.0.1:5678?textline=true&decoder=#testDecoderHandler");
>     }
> }
>
> TestDecoderHandler.java
>
> public class TestDecoderHandler extends ChannelInboundHandlerAdapter {
>
>     private Logger logger = LogManager.getLogger(TestDecoderHandler.class);
>
>     @Override
>     public void channelActive(ChannelHandlerContext ctx) throws Exception {
>
>         Channel inboundChannel = ctx.channel();
>
>         logger.info("ChannelActive");
>         ctx.writeAndFlush("ACK");
>     }
>
>     @Override
>     public void channelRead(ChannelHandlerContext ctx, Object msg) {
>
>         logger.info("ChannelRead");
>
>         ByteBuf msgBuf = (ByteBuf) msg;
>
>         String message = msgBuf.toString(CharsetUtil.UTF_8);
>
>         logger.info(message);
>
>     }
>
>     @Override
>     public void channelReadComplete(ChannelHandlerContext ctx) {
>         logger.info("ChannelReadComplete");
>
>     }
> }
>
> I'm expecting the data to flow from the first netty route, to the seda queue. 
> Then from the seda queue to the destination netty component where first a 
> handshake is performed inside a custom decoder before the received data is 
> sent. Any help would be greatly appreciated.



-- 
Zoran Regvart

Reply via email to