7 Replies Latest reply on Apr 21, 2005 10:42 AM by leonardosalvatore

    Port Listener Services on JBoss

    sandeep_multani

      I am a novice.

      I need to know if there is an underlying architecture in JBoss to manage and access ports ? If it exists is it documented ?

      Purpose: I need to configure a new service to listen to a port and read data ( as specified in a protocol ) and execute some logic. And the load on this port may go upto 5000 connections each managed by a thread ... sort of a small specialised server inside JBoss ....

        • 1. Re: Port Listener Services on JBoss
          dimitris

          With that number of threads/requests you'll almost certainly need a thread pool.

          I don't think there is some "official" JBoss API exposed for this kind of stuff, but you could use as starting points:

          common/src/main/org.jboss.util.threadpool.BasicThreadPool.java

          This is a re-usable simple thread pool implementation. It is used, for example, by:

          naming/src/main/org/jnp/server/Main, NamingServer.java

          which is the embedded JNDI naming server running within JBoss.

          You'll need a basic undestanding of loading your own services in JBoss as MBeans, so read the 2nd chapter of the JBoss Documentation.

          Usually, there is a lot of useful information in the wiki, as well, eg:
          http://www.jboss.org/wiki/Wiki.jsp?page=FAQJBossJMX

          Good luck

          • 2. Re: Port Listener Services on JBoss
            sandeep_multani

            Thanx for the thread pool thing.... Little help with connection to the port part and integration of the service as a JBoss service would be highly appreciated ...

            • 3. Re: Port Listener Services on JBoss

              With 5000 simultaneous connections/threads, I guess you'll kill every os! This is why java NIO selector was introduced - you'll have a small thread pool (10) to handle the connections.

              • 4. Re: Port Listener Services on JBoss
                sandeep_multani

                We will be implementing this as a clustered app ... i think that should be capable of that kind of load(5000 connections) ... any ideas ?

                • 5. Re: Port Listener Services on JBoss
                  dimitris

                  You need to clarify the reasons you want your application to be clustered. Clustering for high availability usually reduces performance due to state replication among cluster nodes. What you need is probably load balancing, but again you need to decide if there is any shared state. In many cases the whole thing depends on the access protocol (http, rmi, other?) and your use cases...

                  • 6. Re: Port Listener Services on JBoss
                    dimitris

                    You may also want to have a look at the JBoss remoting framework.

                    • 7. Re: Port Listener Services on JBoss
                      leonardosalvatore

                      For thread pool i suggest you to try

                      pool = Executors.newCachedThreadPool();
                      or
                      pool = Executors.newFixedThreadPool(poolSize);


                      You have to implement class Handler implements Runnable

                      and
                      serverSocket = new ServerSocket(port);
                      pool.execute(new Handler(serverSocket.accept()));

                      For network communication i also suggest you Jgroups 2