3 Replies Latest reply on Sep 20, 2005 3:40 AM by jaikiran pai

    How to invoke an MDB

    raja raja Newbie

      Hi,

      I packaged an MDB jar file and a session bean in an .ear format... in which the session bean class acts as the client for the MDB. I deployed the ear file and it got deployed.. and the Queue which I created was bound...

      I called the session bean thru a stand alone client and the look up for the Queue executes which I can confirm with the logging .. then I cud see the message in the queue via the jmx console..

      I need help to retrieve the msg from the queue.. cud anyone help me on this

      Thanks in advance
      Raja

        • 1. Re: How to invoke an MDB
          jaikiran pai Master

          When you say you have packaged your MDB in your ear, i assume that you mentioned the necessary details about your MDB in the deployment descriptors as well. One of them being the jndi name of the queue on which this MDB will be listening. So, once the message is there in that particular queue, the onMessage(Message m) method of your MDB will be invoked. The parameter passed to this method will be the message that was sent to the queue

          • 2. Re: How to invoke an MDB
            raja raja Newbie

            Hi Jai,

            do u mean to say me that I need to specify my mdb module in application.xml of the ear file.. if so, is that to be done in the same manner as like that of mentioning my session bean details in the deployment descriptor ..??

            Then where shud I specify the jndi name of the queue.. shud i specify on the application.xml itself.. can u send me a sample deployment descriptor application.xml which has the details abt an MDB

            Thanks in advance
            Raja

            • 3. Re: How to invoke an MDB
              jaikiran pai Master

              You will be making entries for the MDB in ejb-jar.xml and jboss.xml

              In your ejb-jar.xml you will have something like the following:

              <!-- Message Driven Beans -->
               <message-driven >
               <description><![CDATA[<!-- begin-xdoclet-definition -->]]></description>
              
               <ejb-name>MyMDBean</ejb-name>
              
               <ejb-class>com.abc.MyMDBean</ejb-class>
              
               <transaction-type>Bean</transaction-type>
              
               <message-driven-destination>
               <destination-type>javax.jms.Queue</destination-type>
               </message-driven-destination>
              
              
               </message-driven>


              In jboss.xml:

              <message-driven>
               <ejb-name>MyMDBean</ejb-name>
               <destination-jndi-name>queue/YourQueueName</destination-jndi-name>
               </message-driven>


              You have thus configured MyMDBean to listen to queue/YourQueueName queue. Thus whenever a message arrives on the queue/YourQueueName queue, the onMessage method of com.abc.MyMDBean gets called