4 Replies Latest reply on Apr 27, 2010 11:47 AM by faustodelatog

    Control the MDB instance number

    ericmacau

      Hello,

      Is it possible to control the instance number of MDB in JBoss?

      If I send more than one message to the Queue, JBoss will create n-Instances to handle each of those messages).

      I just want to create only one instance to handle all the messages one-by-one. No more than one MDB instance will be created.

      I check the reference, and found that there is a tag
      in <container-pool-conf> and
      in <container-invoker-conf>.

      Is that can limit the instance size? Which one should I use and what is the different between them ?


      Best regards,
      Eric

        • 1. Re: Control the MDB instance number
          nhebert

          Eric,

          Under most situations this is one of those things you
          should not have to worry about! The number of instances
          of an EJB whether it be an MDB, Session or Entity Bean,
          is the responsibility of the application server as part
          of managing resources.

          Why do you want only *one* instance of your MDB? I would
          expect JBoss to take on the responsibility of creating as
          many of your MDB instances as are required to handle the
          inbound message load at that point in time.

          Later, when the message arrival rate decreases, JBoss
          would take on the responsibility of evicting (removing)
          the least recently used MDBs from memory.

          After all this is its responsibility.

          So I will ask the question again.

          Why to you feel that you need only one instance of your
          MDB?

          Cheers,

          Noel.




          • 2. Re: Control the MDB instance number
            ericmacau

            Hi Noel,

            I just want to handle all message one-by-on in order.

            If all the message(transaction) will be handled at the same time(create a new instance). I can't control the real sequence for the submited sequence in the MDB.

            Regards,
            Eric

            • 3. Re: Control the MDB instance number
              nhebert

              G'Day Eric,

              I am still not quite sure what you are trying to
              do.

              >I can't control the real sequence for the submited sequence in the MDB.

              Do the messages on the inbound queue have some relationship
              with one another that processing them in some sequence
              is important?

              Or, does the sequence in which they are read have
              significance to some business process?

              I a trying to understand what you mean by the "real
              sequence" and the "submitted sequence". How are
              they related?

              Cheers,

              Noel.

              • 4. Re: Control the MDB instance number
                faustodelatog

                I had the same problem, the solution is set the maxSession property,

                 

                @MessageDriven(activationConfig = {
                        @ActivationConfigProperty(propertyName = "maxSession", propertyValue = "1"),
                ...

                 

                http://www.jboss.org/file-access/default/members/jbossejb3/freezone/docs/tutorial/1.0.7/html/Message_Driven_Beans.html