1 Reply Latest reply on Feb 19, 2011 1:51 AM by wdfink

    problem with JBoss 6 timer in MDB

    saphir

      Hi,

            I am using JBoss 6 final and I met a very stange problem while start a timer in MDB.

             My propose is to do a batch commit in MDB to database, so I write a List to hold all messges in MDB, when the list size exceed the limit, then commit all the data in the list to database. But, if the list's size not exceed the limit, all data will not be commited. So, I start a timer in the MDB to periodic commit the data to database.

             When I write a @schedule on the commit method in the MDB, there is one timer call a random MDB instance, event more, the timer will create a MDB instance and call it's method. the instance will not listen on the MDB's queue or topic, and the MDB size limit will be exceeded.

              When I create the timer in the onMessage, there is the same thing. Serval timer call a random MDB or create a MDB instance to call. is the timer expected to call the instance which create the timer ? or is there any way to solve my problem?

        • 1. problem with JBoss 6 timer in MDB
          wdfink

          A MDB is a stateless instance, so I think it depends to the implementation how such stateful thing like yours will work.

           

          A timer in this case will call a instance of your MDB without respect the concrete instance, one will taken from the pool and triggered.

          If you use a local collection, it is not deterministic how your threshold is reached.

          A static collection might be better.

          But I think it will be very dangerous, so what about if the server is server is shutdowned? Your pending messages are lost!

          And this will only one of the suspect examples.