7 Replies Latest reply on Aug 1, 2009 6:48 AM by Tim Fox

    JBM with singleton MDB

    Mr. Overlord Newbie

      I'm using JBM 1.4SP3 (or may be SP4), to send messages to a clustered MDB on multiple servers.

      Now these MDBs are defined as MDB singletons (1 maximum MDB instance per server).

      The reason for this is the MDB uses a native library that is not thread safe so it can not allow more than thread to enter at any given time, however, it's totally OK to have multiple of these MDBs running on different machines simultaneously.

      What I found is that JBM will send messages to these MDBs in a round robin fashion but it doesn't seem to detect if a MDB is busy. My observations show that if a singleton MDB is busy and JBM chooses that MDB to consume it's messages, the message will wait on the queue even if other MDBs on other matches are idle.

      Obviously the desired behavior is for JBM to know that a singleton MDB is not available (busy) and send it off to another MDB that is available. That does not appear to be happending.

      I tried setting prefetch size to 1 but that did not help.

      Any ideas on how to get this to work properly?

      Conceptually what I'm trying to do is simple as mud but I can't get it to work properly.



        • 1. Re: JBM with singleton MDB
          Clebert Suconic Master

          On JBM 1.4, the JCA adapter is part of the application server. So MDBs are not really part of JBoss Messaging 1.4. (Differently on JBM 2, as we are writing our own JCA adapter).


          I suggest you ask this on the JCA Forum (http://www.jboss.org/index.html?module=bb&op=viewforum&f=136)


          But anyway, you could also make the method onMessage of your MDB synchronized. So you would solve the multi-thread issue you have at your native lib.

          • 2. Re: JBM with singleton MDB
            Mr. Overlord Newbie

             

            "clebert.suconic@jboss.com" wrote:

            But anyway, you could also make the method onMessage of your MDB synchronized. So you would solve the multi-thread issue you have at your native lib.


            My onMessage is already synchronized but it doesn't really solve my problem.

            A thread can be blocked and idling because the onMessage is currently used, however, other MDBs on other machines are doing absolutely nothing and waiting for messages. The waiting part is what I'm trying to avoid.



            • 3. Re: JBM with singleton MDB
              Clebert Suconic Master

              If I understand correctly, you need to set slowConsumer=true on the ConnectionFactory used by the MDB. You probably don't want any buffer on the client, as you want the message to be round robbed to other servers.


              It' s a bit obscure what you are trying to achieve here.. so I' m suggesting that based on what I understood.

              • 4. Re: JBM with singleton MDB
                Mr. Overlord Newbie

                 

                "clebert.suconic@jboss.com" wrote:
                If I understand correctly, you need to set slowConsumer=true on the ConnectionFactory used by the MDB. You probably don't want any buffer on the client, as you want the message to be round robbed to other servers.


                It' s a bit obscure what you are trying to achieve here.. so I' m suggesting that based on what I understood.


                You seem to understand what I'm trying to do.

                I want maximum throughput of whatever the MDB is doing while honoring the requirements that only one thread can enter the MDB onMessage at a time.

                Messages should not wait for a MDB that's busy. If it's busy, it should go another MDB that is not busy. If all MDBs are busy, it should wait until one isn't busy.

                Very simple.

                I will try the slowConsumer thing to see if it works.

                • 5. Re: JBM with singleton MDB
                  Clebert Suconic Master

                  Cool.. I think it will work then.

                  All you need is to configure the slowconsumer at the Connection Factory used by the JmsXA.

                  BTW: I meant "it's a bit obscure to *me*".. as the problem being me.. not you. :-)

                  (I missed the me because of a typo).


                  Cheers.

                  • 6. Re: JBM with singleton MDB
                    Mr. Overlord Newbie

                    I tried setting slowConsumers to true but it didn't work.

                    The way I test this is that on one server, I set a debug break point at the start of the MDB onMessage method.

                    After a message hits that break point, i'll send more messages. They'll round robin to the other servers but none should return to the server that has hit that break point, but it does !!!

                    So basically the JBM seems to be not aware that the MDB is preoccupied.

                    I would imaging that once a server's MDB pool is exhausted, JBM will choose to use another one from some other server before waiting for one to become available - am I correct in that assumption?

                    • 7. Re: JBM with singleton MDB
                      Tim Fox Master

                      As Clebert mentioned, MDBs are *not* part of JBoss Messaging - JBM has no knowledge of MDBs.

                      MDBs exist as part of JBoss AS. MDBs provide their own pooling and buffering of messages which is not part of JBM.