2 Replies Latest reply on Mar 18, 2007 4:25 PM by Jonas Bergström

    MDB destination issues

    Jonas Bergström Newbie

      Hello.

      It is causing me problems that the destination activation config property is mandatory for MDB's. I was wondering if anyone has solutions or tricks on how to solve them.

      In my deployment scenario I don't know the queue name (i.e. destination) until just prior of load time of my mdb's, i.e. it is unknown at compile time. Is there a way to solve this?

      Also, there may very well be cases where messages that can be handled by the same mdb implementation arrive on different queues, is it possible to deploy an mdb multiple times to receive messages from separate queues?

      Or can't I use mdb's at all if these are my requirements?


      Thanks / Jonas

        • 1. Re: MDB destination issues
          Weston M. Price Master

           


          In my deployment scenario I don't know the queue name (i.e. destination) until just prior of load time of my mdb's, i.e. it is unknown at compile time. Is there a way to solve this?


          Not really. The connection consumer created for your deployment requires the destination to be provided. If you wanted to do a 'trick' I suppose you could provide the value of the destination in your ejb-jar.xml file as a property. At deployment time, JBoss will resolve a property reference to the correct system property. Example

          <destination>${some.destination}</destination>
          


          If you take a look at the messagedriven tests in our testsuite, you can see an example of this. Note, for this to work, the name of the destination would have to be set as a system property somehow prior to your deployment. Note, I don't really recommend doing this as it's non standard behavior but it might get you by.


          Also, there may very well be cases where messages that can be handled by the same mdb implementation arrive on different queues, is it possible to deploy an mdb multiple times to receive messages from separate queues?


          You can't deploy the *same* MDB (ie the same MDB name) to multiple queues, but there is nothing to stop you from deploying the same MDB code with different EJB names to multiple destinations. Example:

          <ejb-name>XListener</ejb-name>
          <ejb-class>org.example.SomeMDB</ejb-class>
          
          <ejb-name>YListener</ejb-name>
          <ejb-class>org.example.SomeMDB</ejb-class>
          
          


          Also, there is nothing to stop you from deploying multiple listeners to a single queue, but only one listener will receive a message, not both. Some people use this scheme as a 'poor man's' load balancing for a single destination.



          • 2. Re: MDB destination issues
            Jonas Bergström Newbie

            Thanks for the quick response!

            So, (I'm quite new to JBoss) is there a way to dynamically and programmatically create such deployments?

            In that case I could read my config with queue names and such when JBoss starts up and create the deployments accordingly, and voilá - home safe.


            / Jonas