10 Replies Latest reply on May 23, 2008 5:20 PM by Scott Queen

    MDB not "watching" queue?

    Scott Queen Newbie

      JBoss 4.2.2
      EJB 2.1

      I have an MDB configured to process messages off of a given queue but it doesn't seem to realize that messages are accumulating in the queue.... it's like it doesn't even see the queue.

      ejb-jar snippet:
      <message-driven>
      <ejb-name>SQMessageHandler</ejb-name>
      <ejb-class>com.scott.messaging.MessageHandlerEJB</ejb-class>
      <messaging-type>javax.jms.MessageListener</messaging-type>
      <transaction-type>Bean</transaction-type>
      <message-selector>selectorKey='order'</message-selector>
      <message-driven-destination>
      <destination-type>javax.jms.Queue</destination-type>
      </message-driven-destination>
      </message-driven>


      jboss.xml snippet:
      <enterprise-beans>
      <message-driven>
      <ejb-name>SQMessageHandler</ejb-name>
      <configuration-name>Standard Message Driven Bean</configuration-name>
      <destination-jndi-name>jms/OrderQueue</destination-jndi-name>
      </message-driven>
      </enterprise-beans>


      Now, jms/OrderQueue is set up properly - I can see messages accumulating in there - I just don't know why these messages aren't being passed to the onMessage method of my MDB...(btw, I know my MDB is built correctly b/c we've been using it under another application server - I'm currently investigation the steps necessary to migrate to JBoss...)

      I hope someone can help!

        • 1. Re: MDB not
          Scott Queen Newbie

          Still battling with this issue.... I downloaded the sample MDB code provided by JBoss and successfully deployed and ran it - it works as expected. Naturally I've compared the configuration of the two applications and made them the same where I could - one difference is that my MDB has a selectorKey whereas the sample doesn't - shouldn't matter.

          One thing I have noticed that seems strange, though is this: when deploying my real app, JBoss sees the MDB and thinks it needs a JNDI name for it - so it creates queue/SQMessageHandler. The server does NOT do the same thing for the sample code (EJB name in that is MessageAccess, but there is no queue/MessageAccess Queue created). It does look like the server creates a couple JNDI references for the EJBs (local/SQMessageHandler and local/MessageAccess)... I'm wondering if there is some problem with having two JNDI entries having the name SQMessageHandler (granted one is local/ and one is queue/ so it shouldn't matter)....

          does that trigger any thoughts?

          • 2. Re: MDB not
            Scott Queen Newbie

            ok... the tail end of that post was a bit confusing: when deploying my app, JBoss sees my MDB and creates BOTH a JNDI name for it (queue/SQMessageHandler) AND a Queue (named SQMessageHandler, referenced by JNDI queue/SQMessageHandler)....

            hopefully that's clearer

            • 3. Re: MDB not
              Scott Queen Newbie

              got this thing working - looks like a bug in the JBoss MDB deployer code... basically the deployer was not paying any attention to the destination-jndi-name that I provided for the EJB in the jboss.xml file. Instead, it would see that I'm deploying SQMessageHandler, realize that there was no queue having that name, and create it. THIS (queue/SQMessageHandler) is the queue that the MDB was monitoring for messages - not the one I specified. So - posting messages to queue/SQMessageHandler works. I ended up changing the EJB name to OrderQueue and that works (except that I can't post to jms/OrderQueue - it has to be queue/OrderQueue).

              • 4. Re: MDB not
                jaikiran pai Master

                 

                "scooter4j" wrote:
                got this thing working - looks like a bug in the JBoss MDB deployer code... basically the deployer was not paying any attention to the destination-jndi-name that I provided for the EJB in the jboss.xml file. Instead, it would see that I'm deploying SQMessageHandler, realize that there was no queue having that name, and create it. THIS (queue/SQMessageHandler) is the queue that the MDB was monitoring for messages - not the one I specified. So - posting messages to queue/SQMessageHandler works. I ended up changing the EJB name to OrderQueue and that works (except that I can't post to jms/OrderQueue - it has to be queue/OrderQueue).


                It's not a bug with the MDB deployer. You probably have not setup the queue configuration correctly. You probably have not set the JNDIName attribute the queue configuration, because of which the queue is being bound by default to queue/OrderQueue. See this for more details http://docs.jboss.org/jbossas/jboss4guide/r1/html/ch6.chapt.html#d0e14693

                • 5. Re: MDB not
                  Scott Queen Newbie

                  I had correctly set up the queue correctly using the JNDIName attribute - and after starting JBoss the queue showed up in the Administration console as expected.... so I'm confident my queue was set up correctly.

                  The link below indicates that this (MDB deployer not "seeing" the destination queue) is a recognized bug in JBoss when using EJB3:
                  http://jira.jboss.org/jira/browse/EJBTHREE-541?page=all

                  Not sure if this means that I'm encountering the same root problem as was encountered for that bug report (since I'm not using annotations).

                  I will grant you, though, that it is strange that the MDB sample worked correctly, not creating a special Queue/JNDI name for its MDB.... perhaps the problem is that the JNDI name I specified starts with jms instead of queue (i.e. jms/OrderQueue instead of queue/OrderQueue)??

                  • 6. Re: MDB not
                    jaikiran pai Master

                     

                    "scooter4j" wrote:
                    I had correctly set up the queue correctly using the JNDIName attribute - and after starting JBoss the queue showed up in the Administration console as expected.... so I'm confident my queue was set up correctly.

                    The link below indicates that this (MDB deployer not "seeing" the destination queue) is a recognized bug in JBoss when using EJB3:
                    http://jira.jboss.org/jira/browse/EJBTHREE-541?page=all



                    Can you post the contents of the xml file in which you have configured your queue? Also, where have you place this file and what have you named it? As for the bug that you pointed to, i don't think that should affect users of JBoss-4.2.x.

                    P.S: While posting the logs or xml content or code, remember to wrap it in a code block using the Code button in the message editor window and please hit the Preview button to make sure your post is correctly formatted

                    • 7. Re: MDB not
                      Scott Queen Newbie

                      well... i deleted the contents of the file related to that queue b/c it wasn't working... but this is what I'm pretty sure I had:

                       </mbean>
                       <mbean code="org.jboss.mq.server.jmx.Queue"
                       name="jboss.mq.destination:service=Queue,name=OrderQueue">
                       <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
                       <attribute name="JNDIName">jms/OrderQueue</attribute>
                       </mbean>
                      


                      btw: the file in which I put this block is $JBOSS_INSTALL\server\default\deploy\jms\jbossmq-destinations-service.xml

                      • 8. Re: MDB not
                        Scott Queen Newbie

                        note the poor copy-paste results the code section of previous post... i included the closing mbean tag from the previous element...

                        • 9. Re: MDB not
                          Scott Queen Newbie

                          pretty sure I found the problem (can't verify for a bit but wanted to put this here before I forget).... I think the problem is that I neglected to put the jboss.xml file in my ear file :( I found that my build script was sending it somewhere other than the ear file.... will try to confirm in the near future.

                          • 10. Re: MDB not
                            Scott Queen Newbie

                            confirmed. I had left the jboss.xml file out of the ear file. when I included it (and re-added the JNDIName attribute to the jbossmq-destinations-service.xml file) it worked as expected.