4 Replies Latest reply on Nov 8, 2013 6:08 AM by olli24

    How to order deployment of EJBs and JMS queue config?

    mluisbrown

      I have an EAR which contains an EJB jar that contains some MDBs which depend on the existence of the JMS queues that they use. When I configured the queues in .../server/all/deploy/messaging/myqueues-service.xml there was no problem. However, I wanted to configure the queues in the EAR file to avoid having to make changes to the JBoss config directly. No problem, I put my myqueues-service.xml file into the root of the EAR and added the reference to my jboss-app.xml:

       

      <jboss-app>
           <module-order>strict</module-order>
      <loader-repository>
      seam.jboss.org:loader=pce-ear.ear
      </loader-repository>
      <module>
      <service>gfdqueue-service.xml</service>
      </module>
      </jboss-app>

      <jboss-app>
            <module-order>strict</module-order>
           <loader-repository>
                seam.jboss.org:loader=my-ear.ear
           </loader-repository>
           <module>
                <service>myqueues-service.xml</service>
           </module>
      </jboss-app>
      
      

       

      However, when I do that, JBoss loads the EJB jar (contained in my-ear.ear) first and then configures the JMS Queues afterwards. This results in errors when the MDB are loaded:

       

      12:16:02,714 WARN  [JmsActivation] Failure in jms activation org.jboss.resource.adapter.jms.inflow.JmsActivationSpec@13a59e .....
      javax.naming.NameNotFoundException: MyQueue not bound
      
      

       

      It's not a huge problem, as later on the MDBs successfully reconnect to JMS:

       

      12:16:12,698 INFO  [JmsActivation] Attempting to reconnect org.jboss.resource.adapter.jms.inflow.JmsActivationSpec@f91ad5
      12:16:12,823 INFO  [JmsActivation] Reconnected with messaging provider.
      
      
      But I'd really like to avoid having any errors, and in order to do that I need a way to force JBoss to configure the JMS queues first, before loading the EJB jar. Is there any way to do this? For reference, here's the application.xml for the EAR:
      <application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:application="http://java.sun.com/xml/ns/javaee/application_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd" version="5">
        <display-name>my-ear</display-name>
        <module>
          <ejb>my-ejb.jar</ejb>
        </module>
        <module>
          <web>
            <web-uri>my.war</web-uri>
            <context-root>myroot</context-root>
          </web>
        </module>
      </application>
      
      Any suggestions appreciated. Oh yeah, I'm using JBoss [EAP] 5.0.0.GA.

        • 1. Re: How to order deployment of EJBs and JMS queue config?
          jaikiran

          Add a dependency (either in jboss.xml or via @org.jboss.ejb3.annotation.Depends annotation) between the MDB and the JMS destination's MBean. Here's an example http://anonsvn.jboss.org/repos/jbossas/projects/ejb3/trunk/docs/tutorial/mdb/src/org/jboss/tutorial/mdb/bean/ExampleMDB.java

          • 2. Re: How to order deployment of EJBs and JMS queue config?
            mluisbrown
            Thanks Jaikiran! That's solved the problem. Just worth pointing out that the Depends annotation example you linked to was for a JBoss MQ queue (
            jboss.mq.destination) when I'm using JBoss Messaging, so in my case the annotation I had to use was:
            @Depends("jboss.messaging.destination:service=Queue,name=GfdQueue")
            @Depends("jboss.messaging.destination:service=Queue,name=MyQueue")
            Thanks again!

            Thanks Jaikiran! That's solved the problem. Just worth pointing out that the Depends annotation example you linked to was for a JBoss MQ queue (jboss.mq.destination) when I'm using JBoss Messaging, so in my case the annotation I had to use was:

             

            @Depends("jboss.messaging.destination:service=Queue,name=MyQueue")

             

            Thanks again!

             

            • 3. Re: How to order deployment of EJBs and JMS queue config?
              jaikiran

              Michael Brown wrote:

               

              Thanks Jaikiran! That's solved the problem. Just worth pointing out that the Depends annotation example you linked to was for a JBoss MQ queue (
              jboss.mq.destination) when I'm using JBoss Messaging, so in my case the annotation I had to use was:
              @Depends("jboss.messaging.destination:service=Queue,name=GfdQueue")
              @Depends("jboss.messaging.destination:service=Queue,name=MyQueue")
              Thanks again!

              Just worth pointing out that the Depends annotation example you linked to was for a JBoss MQ queue (jboss.mq.destination) when I'm using JBoss Messaging, so in my case the annotation I had to use was:

               

              @Depends("jboss.messaging.destination:service=Queue,name=MyQueue")
              

               

               

               

              Yeah, that's a good point.

              • 4. Re: How to order deployment of EJBs and JMS queue config?
                olli24

                I have a similar problem under EAP 6.1.

                -> My MDB is deployed before the JMS queue is configured.

                 

                But I want to use the solution with adding the dependency via jboss-ejb3.xml.

                Could someone give me a short example how to define the @Depends via xml deploy descriptor.

                 

                I tried following deployment descriptor, but the deployment fails, because the tag <depends> is not supported.

                Unexpected element '{http://java.sun.com/xml/ns/javaee}depends' encountered

                JBAS014185: Exception while parsing jboss-ejb3.xml

                 

                    <message-driven>
                        <ejb-name>CommCalMDB</ejb-name>
                        <depends>jboss.messaging.destination:service=Queue,name=myQueue</depends>
                        <activation-config>
                            <activation-config-property>
                                <activation-config-property-name>destination</activation-config-property-name>
                                <activation-config-property-value>jms/queue/myQueue</activation-config-property-value>
                            </activation-config-property>
                        </activation-config>
                    </message-driven>

                 

                How can a MDB dependency on a JMS queue set via deployment descriptor?

                 

                Or is there another way, that JBoss first configures the JMS queues (defined in standalone.xml), before starting the deployment and activating the MDB?

                Thanks.