3 Replies Latest reply on Jun 6, 2013 2:00 PM by jesper.pedersen

    How use AsynchronousServerSocketChannel with JCA 1.6 ?

    rockerced

      Hello at all,

       

      I want to develop a AsynchronousServerSocketChannel with NIO.2 by using ThreadGroup with JCA 1.6. But I doesn't know how use AsynchronousChannelGroup with the javax.resource.spi.work.Work interface.
      In the example of google jca-sockets implementation. When a new client is accepted (ServerSocket) a work is created to manage socket client.

       

      INBOUND mode in JCA 1.6

       

      Exemple of code for asynchronous server :
          ExecutorService es = Executors.newCachedThreadPool();
          if (es instanceof ThreadPoolExecutor){
          ((ThreadPoolExecutor)es).setMaximumPoolSize(serverInfo.getMaxThread());
          }
          AsynchronousChannelGroup threadGroup = AsynchronousChannelGroup.withCachedThreadPool(es,serverInfo.getMinThread());

       

          /*server configuration*/
          SocketAddress sa = new InetSocketAddress(Inet4Address.getByName(socketInfo.getHost()), socketInfo.getPort());

       

          /*server instantiation*/
          server = AsynchronousServerSocketChannel.open(threadGroup).bind(sa);

       

      Thread management is performed by AsynchronousChannelGroup.

       

      Is it necessary to use only ServerSocket for JCA 1.6 implementation ?

       

      Can you give an example of implementation ?

       

      Best regards
      GOSSET Cédric