Package org.apache.mina.transport.socket.nio

Examples of org.apache.mina.transport.socket.nio.SocketConnector


    public void testProducerShutdownTestingWithMock() throws Exception {
        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedBodiesReceived("Hello World");

        // create our mock and record expected behavior = that worker timeout should be set to 0
        SocketConnector mockConnector = createMock(SocketConnector.class);
        mockConnector.setWorkerTimeout(0);
        replay(mockConnector);

        // normal camel code to get a producer
        Endpoint endpoint = context.getEndpoint("mina:tcp://localhost:{{port}}?textline=true&sync=false");
        Exchange exchange = endpoint.createExchange();
View Full Code Here


        ExecutorService acceptorPool = getCamelContext().getExecutorServiceManager().newCachedThreadPool(this, "MinaSocketAcceptor");
        ExecutorService connectorPool = getCamelContext().getExecutorServiceManager().newCachedThreadPool(this, "MinaSocketConnector");
        ExecutorService workerPool = getCamelContext().getExecutorServiceManager().newCachedThreadPool(this, "MinaThreadPool");

        IoAcceptor acceptor = new SocketAcceptor(processorCount, acceptorPool);
        IoConnector connector = new SocketConnector(processorCount, connectorPool);
        SocketAddress address = new InetSocketAddress(configuration.getHost(), configuration.getPort());

        // connector config
        SocketConnectorConfig connectorConfig = new SocketConnectorConfig();
        // must use manual thread model according to Mina documentation
View Full Code Here

    public void startWriter() throws IOException, InterruptedException
    {
        IoConnector ioConnector = null;

        ioConnector = new SocketConnector();
       
        SocketConnectorConfig cfg = (SocketConnectorConfig) ioConnector.getDefaultConfig();
        cfg.setThreadModel(ThreadModel.MANUAL);
        SocketSessionConfig scfg = (SocketSessionConfig) cfg.getSessionConfig();
        scfg.setTcpNoDelay(true);
View Full Code Here

        _count = count;
        _size = size;
        AMQDataBlock block = BasicDeliverTest.getDataBlock(size);

        InetSocketAddress address = new InetSocketAddress(host, port);
        ConnectFuture future = new SocketConnector().connect(address, this);
        future.join();
        _session = future.getSession();

        _start = System.currentTimeMillis();
        for(int i = 0; i < count; i++)
View Full Code Here

    }

    protected MinaEndpoint createSocketEndpoint(String uri, URI connectUri) {
        IoAcceptor acceptor = new SocketAcceptor();
        SocketAddress address = new InetSocketAddress(connectUri.getHost(), connectUri.getPort());
        IoConnector connector = new SocketConnector();

        // TODO customize the config via URI
        SocketConnectorConfig config = new SocketConnectorConfig();
        config.getFilterChain().addLast("codec", new ProtocolCodecFilter(new ObjectSerializationCodecFactory()));
View Full Code Here

        // Create I/O and Protocol thread pool filter.
        // I/O thread pool performs encoding and decoding of messages.
        // Protocol thread pool performs actual protocol flow.
        ThreadPoolFilter ioThreadPoolFilter = new ThreadPoolFilter();
        ThreadPoolFilter protocolThreadPoolFilter = new ThreadPoolFilter();
        IoConnector connector = new SocketConnector();
        connector.getDefaultConfig().getFilterChain().addFirst(
                "ioThreadPool", ioThreadPoolFilter );
        connector.getDefaultConfig().getFilterChain().addLast(
                "protocolThreadPool", protocolThreadPoolFilter );

        // Set connect timeout.
        ( ( IoConnectorConfig ) connector.getDefaultConfig() ).setConnectTimeout( CONNECT_TIMEOUT );
       
        IoSession session;
        for( ;; )
        {
            try
            {
                ConnectFuture future = connector.connect(
                        new InetSocketAddress( HOSTNAME, PORT ),
                        new ClientSessionHandler( USE_CUSTOM_CODEC, values ) );
               
                future.join();
                session = future.getSession();
View Full Code Here

            System.out.println( Main.class.getName() + " <hostname> <port>" );
            return;
        }

        // Create TCP/IP connector.
        SocketConnector connector = new SocketConnector();

        // Set connect timeout.
        ( ( IoConnectorConfig ) connector.getDefaultConfig()).setConnectTimeout( 30 );
       
        // Start communication.
        connector.connect(
                new InetSocketAddress( args[ 0 ],
                Integer.parseInt( args[ 1 ] ) ),
                new NetCatProtocolHandler() );
    }
View Full Code Here

        connectorSSLFilter.setUseClientMode( true ); // set client mode
    }

    public void testTCP() throws Exception
    {
        IoConnector connector = new SocketConnector();
        testConnector( connector );
    }
View Full Code Here

   
    public void testTCPWithSSL() throws Exception
    {
        useSSL = true;
        // Create a connector
        IoConnector connector = new SocketConnector();
       
        // Add an SSL filter to connector
        connector.getDefaultConfig().getFilterChain().addLast( "SSL", connectorSSLFilter );
        testConnector( connector );
    }
View Full Code Here

            System.out.println(Main.class.getName() + " <hostname> <port>");
            return;
        }

        // Create TCP/IP connector.
        SocketConnector connector = new SocketConnector();

        // Set connect timeout.
        ((IoConnectorConfig) connector.getDefaultConfig())
                .setConnectTimeout(15);

        // Start communication.
        ConnectFuture cf = connector.connect(new InetSocketAddress(
                args[0], Integer.parseInt(args[1])), new NetCatProtocolHandler());
       
        // Wait for the connection attempt to be finished.
        cf.join();
        cf.getSession();
View Full Code Here

TOP

Related Classes of org.apache.mina.transport.socket.nio.SocketConnector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.