Return-Path: X-Original-To: apmail-camel-dev-archive@www.apache.org Delivered-To: apmail-camel-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 22F7E9CBC for ; Tue, 25 Oct 2011 11:50:57 +0000 (UTC) Received: (qmail 57630 invoked by uid 500); 25 Oct 2011 11:50:57 -0000 Delivered-To: apmail-camel-dev-archive@camel.apache.org Received: (qmail 57591 invoked by uid 500); 25 Oct 2011 11:50:56 -0000 Mailing-List: contact dev-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list dev@camel.apache.org Received: (qmail 57583 invoked by uid 99); 25 Oct 2011 11:50:56 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Oct 2011 11:50:56 +0000 X-ASF-Spam-Status: No, hits=-2000.5 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Oct 2011 11:50:53 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 02C5B31A56C for ; Tue, 25 Oct 2011 11:48:33 +0000 (UTC) Date: Tue, 25 Oct 2011 11:48:33 +0000 (UTC) From: "Claus Ibsen (Updated) (JIRA)" To: dev@camel.apache.org Message-ID: <834452522.12889.1319543313012.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (CAMEL-3607) How to set receiveBufferSizePredictor option in Camel-netty udp consumer server? MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/CAMEL-3607?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Claus Ibsen updated CAMEL-3607: ------------------------------- Fix Version/s: (was: 2.9.0) 2.10 > How to set receiveBufferSizePredictor option in Camel-netty udp consumer server? > --------------------------------------------------------------------------------- > > Key: CAMEL-3607 > URL: https://issues.apache.org/jira/browse/CAMEL-3607 > Project: Camel > Issue Type: Improvement > Components: camel-netty > Affects Versions: 2.6.0 > Reporter: JungHo Cha > Priority: Minor > Fix For: 2.10 > > > Hello, > I am trying to build the camel netty udp consumer. > My spring XML like the below : > > > > > > > > > > > ... > My test udp packet size is over 1000 bytes. > When my udp client sent the udp packet, Netty consumer did not receive the full packet data, > Instead netty decode() callback received only 768 bytes. And no another call happened. > Then I googled this problem, So I found the receiveBufferSizePredictor field in DatagramChannelConfig Class was related received udp packet size. > If receiveBufferSizePredictor is set bigger than the real udp packet, It might be that this problem can be cleared. > But.. > I cannot find this receiveBufferSizePredictor option in The Camel Netty options. > And I have no idea this option where to insert after reviewing camel netty source too. > 11:04:09,660 [DEBUG] [New I/O datagram worker #1'-'1] [NettyDecoder] (NettyDecoder.java:17) - decode(ChannelHandlerContext, Channel, ChannelBuffer) - start > 11:04:09,660 [DEBUG] [New I/O datagram worker #1'-'1] [NettyDecoder] (NettyDecoder.java:20) - receivedBytes = 768 > 11:04:09,676 [DEBUG] [New I/O datagram worker #1'-'1] [ServerChannelHandler] (ServerChannelHandler.java:83) - Incoming message: 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567 > The above number 768 may be related the option "receiveBufferSizePredictor" > I guess if the receiveBufferSizePredictor size is set over the expected received packet size, > Netty decode method is fired when all data is received or receiveBufferSizePredictor size data is received. > I think that netty developer thinks of the receiving memory usage optimazation. > i.e. the receiveBufferSizePredictor is the key for tunning network and memory balance. > Just from my guess... > This receiveBufferSizePredictor option is really critical when camel netty udp consumer wants to receive some big size udp packet. > I think this receiveBufferSizePredictor is included in the camel netty option. > or it is happy if netty global or session options are accesible via camel netty method or injected camel netty configuration. > Thank a lot. > package com.brm.test.netty; > import org.apache.log4j.Logger; > import org.jboss.netty.buffer.ChannelBuffer; > import org.jboss.netty.channel.Channel; > import org.jboss.netty.channel.ChannelHandlerContext; > import org.jboss.netty.handler.codec.frame.FrameDecoder; > public class NettyDecoder extends FrameDecoder { > private static final Logger logger = Logger.getLogger(NettyDecoder.class); > @Override > protected Object decode(ChannelHandlerContext channelhandlercontext, > Channel channel, ChannelBuffer channelbuffer) throws Exception { > logger.debug("decode(ChannelHandlerContext, Channel, ChannelBuffer) - start"); > int receivedBytes = channelbuffer.readableBytes(); > logger.debug("receivedBytes = " + receivedBytes); > byte[] dst = new byte[receivedBytes]; > channelbuffer.readBytes(dst); > return new String(dst); > } > } > ===================== > package com.brm.test.netty; > import java.io.IOException; > import java.net.DatagramPacket; > import java.net.DatagramSocket; > import java.net.InetAddress; > import java.net.UnknownHostException; > public class UDPClient { > public static void main(String args[]) { > DatagramSocket dsock = null; > InetAddress inetAddr = null; > String localhost = "127.0.0.1"; > int port = 164; > int packetSize = 1000; > String value = ""; > try { > inetAddr = InetAddress.getByName(localhost); > dsock = new DatagramSocket(); > for (int i = 0; i < packetSize; i++) { > value += i % 10; > } > byte[] messageBytes = value.getBytes(); > DatagramPacket sendLog = new DatagramPacket(messageBytes, > messageBytes.length, inetAddr, port); > dsock.send(sendLog); > dsock.close(); > } catch (UnknownHostException uhe) { > System.out.println(uhe); > } catch (IOException ie) { > System.out.println(ie); > } catch (Exception e) { > System.out.println(e); > } finally { > if (dsock != null) { > dsock.close(); > } > } > } > } > ================================= > package com.brm.test.netty; > import org.apache.camel.spring.Main; > public class UDPServer { > private Main main; > public static void main(String[] args) throws Exception { > UDPServer udpServer = new UDPServer(); > udpServer.boot(); > } > public void boot() throws Exception { > main = new Main(); > main.enableHangupSupport(); > main.setApplicationContextUri("classpath:com/brm/test/netty/udp-test.xml"); > System.out.println("Starting UDPServer... Use ctrl + c to terminate the JVM.\n"); > main.run(); > } > } > ==================================== > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" > xmlns:util="http://www.springframework.org/schema/util" xmlns:camel="http://camel.apache.org/schema/spring" > xsi:schemaLocation="http://www.springframework.org/schema/beans > http://www.springframework.org/schema/beans/spring-beans-3.0.xsd > http://www.springframework.org/schema/context > http://www.springframework.org/schema/context/spring-context-3.0.xsd > http://www.springframework.org/schema/util > http://www.springframework.org/schema/util/spring-util.xsd > http://camel.apache.org/schema/spring > http://camel.apache.org/schema/spring/camel-spring-2.5.0.xsd"> > > > > > > > > > > > > ================================= > > 4.0.0 > CAMEL-NETTY-TEST > CAMEL-NETTY-TEST > 0.0.1-SNAPSHOT > > > org.apache.camel > camel-netty > 2.5.0 > compile > > > org.apache.camel > camel-spring > 2.5.0 > compile > > > log4j > log4j > 1.2.12 > jar > compile > > > -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira