2 Replies Latest reply on Dec 28, 2010 5:58 AM by piotrekde

    Alternative to Stateful bean with Timer

    piotrekde

      Hi,

       

      I am developing application in which beans communicates with network routers (using snmp protocol). Every 5 seconds routers has to be queried to return some information. So I developed stateful bean that holds all properties required to communicate with router, and also exposes business method sendRequest(...).  The problem is: how to call this method every 5 seconds? The perfect solution would be to use stateful session bean with timer service - unfortunately it is forbidden by EJB specification. I don't want to make this developed bean stateless, because it holds some important information about current connection (router IP, port, community name, protocol and so on), so passing all those information every 5 seconds would be inconvenient (that's first), and also harm the scalability (that's second - more important). I need to have multiple instances of this bean, because many routers are queried the same time. Do I have any alternative?

       

      Thank you in advance!

      Piotr

        • 1. Re: Alternative to Stateful bean with Timer
          jaikiran

          In EJB3.1 which is available in JBoss AS6, you have  @Singleton beans which can hold state. @Singleton beans can also use the TimerService unlike @Stateful. So give it a try in EJB3.1

          • 2. Re: Alternative to Stateful bean with Timer
            piotrekde

            Thanks for answer Jaikiran. Unfortunately I cannot use JBoss AS6 because other parts of application has been designed to work with JBoss 5.0.0.GA and uses some non-standard features. Because of this I cannot take into consideration migration to newer application server.

            Secondly I need multiple instances of this beans, because each one holds connection to another router (with all connection-related properties).