‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Sunday, June 9, 2019 3:33 PM, canukit <[email protected]> wrote:
> Hi Alex thanks a lot for the response. I've tried removing the textline=true > but the same behavior occurs. > > My understanding so far is that since my '.to(netty4...' component is > connected to the server 127.0.0.1:5678 i am activating that channel and am > able to read/write from it using the decoder, but I am lost as to how to get > the message from the SEDA queue through to that server. > > The behavior right now seems to be > > netty(127.0.0.1:1234) --> seda --/-- netty(127.0.0.5678) <--> server > > and I'm trying to achieve (similar behavior as below works when no decoder is > attached) > > 127.0.0.1:1234 --> netty --> seda --> netty(127.0.0.5678) <--> sever > > but I cannot seem to figure out how to achieve this with the decoder in place. > > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ > On Sunday, June 9, 2019 2:23 PM, Alex Dettinger <[email protected]> wrote: > >> Just a try but I wonder if the "decoder" plays well with "textline=true". >> So, perharps removing that could help. >> More info in the doc there: >> https://github.com/apache/camel/blob/master/components/camel-netty4/src/main/docs/netty4-component.adoc >> >> My 2 cents, >> Alex >> >> 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.
