1 Reply Latest reply on Feb 22, 2002 11:19 PM by Hiram Chirino

    Apparent Advantages of MDBs Not So Apparent?

    Nathan W. Phelps Novice

      I've been reading a lot about EJB 2.0 and the addition of MDBs, so I decided to play around with them. One of the supposed advantages of MDBs is that the EJB container can instantiate several instances of a MDB to currencurenlty process messages. I would have assumed that this would translate into faster processing of messages. However, when I tested this, it was actually slower.

      I created a single MDB that simply does a System.out.println(message.toString()) in the onMessage event and a simple stand-alone message listener that did the same. I then sent various numbers of messages to the queue (from 5 to 20,000), started up the message listener (or deployed the MDB) and timed how long it took to process all the messages. The stand-alone message listener always processed the messages faster than the MDB.

      Isn't this backward?

        • 1. Re: Apparent Advantages of MDBs Not So Apparent?
          Hiram Chirino Expert

          It all depends what that processing involes. If the processing is in effect an no-op, then yes you are right.

          I can garantee you that a MSDOS machine can do 1000 no-ops faster than the same machine running Windows XP with 10 dos windows each doing 100 no-op iterations.

          Why??? Less context switching and overhead.

          Now if processing each message takes time due to blocking calls like db access. Then it will be faster.
          Just simulate it with a sleep 500 in your processing.

          Regards,
          Hiram