Search in sources :

Example 61 with ConnectionlessBootstrap

use of org.jboss.netty.bootstrap.ConnectionlessBootstrap in project pinpoint by naver.

the class NettyUdpReceiverTest method createUdpServer.

private ConnectionlessBootstrap createUdpServer() {
    DatagramChannelFactory udpFactory = new NioDatagramChannelFactory(Executors.newCachedThreadPool(), 4);
    ChannelPipelineFactory pipelineFactory = new ChannelPipelineFactory() {

        @Override
        public ChannelPipeline getPipeline() throws Exception {
            ChannelPipeline pipeline = Channels.pipeline();
            pipeline.addLast("test", new SimpleChannelHandler() {

                @Override
                public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
                    String name = Thread.currentThread().getName();
                    logger.debug("sleep:{}", name);
                    Thread.sleep(10000);
                    // if (!name.equals("New I/O worker #1")) {
                    logger.debug("messageReceived thread-{} message:", Thread.currentThread().getName());
                // }
                }
            });
            return pipeline;
        }
    };
    ConnectionlessBootstrap udpBootstrap = new ConnectionlessBootstrap(udpFactory);
    udpBootstrap.setPipelineFactory(pipelineFactory);
    return udpBootstrap;
}
Also used : NioDatagramChannelFactory(org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory) DatagramChannelFactory(org.jboss.netty.channel.socket.DatagramChannelFactory) NioDatagramChannelFactory(org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory) IOException(java.io.IOException) ConnectionlessBootstrap(org.jboss.netty.bootstrap.ConnectionlessBootstrap)

Aggregations

ConnectionlessBootstrap (org.jboss.netty.bootstrap.ConnectionlessBootstrap)61 ChannelPipeline (org.jboss.netty.channel.ChannelPipeline)50 ServerBootstrap (org.jboss.netty.bootstrap.ServerBootstrap)47 TrackerServer (org.traccar.TrackerServer)46 StringEncoder (org.jboss.netty.handler.codec.string.StringEncoder)24 StringDecoder (org.jboss.netty.handler.codec.string.StringDecoder)20 NioDatagramChannelFactory (org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory)10 CharacterDelimiterFrameDecoder (org.traccar.CharacterDelimiterFrameDecoder)10 LengthFieldBasedFrameDecoder (org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder)8 InetSocketAddress (java.net.InetSocketAddress)7 ChannelPipelineFactory (org.jboss.netty.channel.ChannelPipelineFactory)4 FixedReceiveBufferSizePredictorFactory (org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory)4 LineBasedFrameDecoder (org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder)4 DatagramChannelFactory (org.jboss.netty.channel.socket.DatagramChannelFactory)3 IOException (java.io.IOException)2 Map (java.util.Map)2 Channel (org.jboss.netty.channel.Channel)2 FixedLengthFrameDecoder (org.jboss.netty.handler.codec.frame.FixedLengthFrameDecoder)2 Test (org.junit.Test)2 ServerPipelineFactory (com.jcumulus.server.rtmfp.ServerPipelineFactory)1