4 Replies Latest reply on Oct 31, 2003 8:01 AM by Pedro Salazar

    reset a field of entity bean on application server start (~c

    Pedro Salazar Newbie

      Greetings,

      I have a entity bean that is related to a table X. In this table, I need to monitor a field that is a counter. When a user connects, I go to this field and I increment it. When the use leaves, I go back there and decrement it.

      Now my problem is, what should happen if the application server restarts? Probably the counter would in the last numbert before stops. So, I want to reset or force that field (counter) to 0 (zero).

      How can I do it? I should have the jboss in cluster...

      thanks,
      Pedro Salazar.

        • 1. Re: reset a field of entity bean on application server start
          Adrian Brock Master

          So when does the cluster restart? :-)

          The spec compliant method is use an init() on a servlet.

          You can also use an MBean.

          Regards,
          Adrian

          • 2. Re: reset a field of entity bean on application server start
            Pedro Salazar Newbie

            > So when does the cluster restart? :-)
            >

            Yes, how to know that... :-)

            > The spec compliant method is use an init() on a
            > servlet.
            >

            What do you mean? I didn't get it...

            > You can also use an MBean.
            >

            I'm not familiar with MBeans. Are them related to JMX? Can you give some directions...

            So, in JBOSS cluster is there any way to track users requests? I'm using a Web services handler to catch the entrance and the exit... But, what happens in a maintenance operation where a jboss cluster instance goes down...How do I prevent that all the users pending requests are shutdown and cleaned on my database/entity beans?

            regards,
            Pedro Salazar.

            • 3. Re: reset a field of entity bean on application server start
              Adrian Brock Master

              I was joking about a cluster restart.
              A cluster shouldn't restart ideally, there will always be
              an instance running.

              Read the servlet or JMX spec.

              See above, why would the cluster ever go down?
              I don't follow your requirement?

              If you specifically take down the whole the cluster,
              why don't you set some state somewhere (the db?)
              that says clean the db.
              First one to see the "clean" flag resets it and performs the
              clean, select for update would be a good way to
              hold competing machines.

              Regards,
              Adrian

              • 4. Re: reset a field of entity bean on application server start
                Pedro Salazar Newbie

                How can we do a safety shutdown of a single JBOSS instance? In every second, requests are entering the system. If I apply a politic to increase the count a user request in the system, and decrease it when it leaves, during the operation a jboss instance handling that request goes down.

                What happens now? Other jboss instance will assume the pending jobs?

                How can I improve the performance, the only way of synchronization of entity beans is through the database, right?

                If a entity bean could be almost the time updating the counter, it should occurs stores in database every time, right? And, entity beans should be clustered? (since we have the database working on persistence...) Are entity beans adequate for the job? Could it be better doing a JDBC procedure to do this?

                I'm trying to improve a solution but I'm really not experienced with J2EE and I would like to avoid system design errors!!

                Any precious hints?

                regards,
                Pedro Salazar.