3 Replies Latest reply on Jul 17, 2003 11:08 AM by Sascha Kulawk

    MDB working as a singleton vs MBean

    calimero Newbie

      Hi all,

      I'm quite new to EJB's world and need an advise.

      I know that J2EE architecture is not thought to be able to manage singletons but in my current project, I will definitly have to cope with it.

      Somewhere in my stuff, I'll need a bean working as a sequencer e.g. something receiving messages and able to forward them in the right order.

      what should I do ?

      1° write an MDB, limit pool size to 1 and make sure to manage its persistence (by using NonSerializableFactory or DB storage for instance)
      2° write an MBean listening to the queues and in that case, will I be sure that only ONE instance of my MBean will be running in the same time ?
      3° as JMS destinations are still accessible outside of the server VM, should I use a standalone CORBA server just for the sorting stuff ?

      Would someone be kind enough to remind me the assets of using MBeans apart from their being manageable ?

      Many thanks for your help.

        • 1. Re: MDB working as a singleton vs MBean
          Peter Antman Expert

          Hi, I have to admit that I am not shure what you are after, but I know this much:

          1. An MDB with a pool size set to one, and listening on a queue should receive its messages in the order they where sent.

          2. To create a singleton you could use a singleton deployment descriptor for a session bean, to get only one active instance (JBoss specific - look into the manual).


          • 2. Re: MDB working as a singleton vs MBean
            calimero Newbie

            Hi Peter,

            Thanks for your answer.

            Actually, my question was only about the different means to create singleton beans. :-)

            I think I'd probably write the MDB.

            • 3. Re: MDB working as a singleton vs MBean
              Sascha Kulawk Newbie

              Hi Peter,

              I'm still in trouble creating a MDB which will only spawn one Instance for the queue.
              My curent jboss.xml looks like:

              <container-configuration extends="Standard Message Driven Bean">




              And with this Container Configuration it is possible to deploy the MDB with just one instance.
              IMHO it is not the best method to define invoker-proxy-bindings, but I havent found another method.
              Do you know how I can handle this?

              Thanks a lot,