Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to order deployment of EJBs and JMS queue config in JBoss 5?

I'm using JBoss [EAP] 5.0.0.GA and 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 as follows:

<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.

like image 987
mluisbrown Avatar asked Jan 06 '11 14:01

mluisbrown


1 Answers

Ok, jaikiran pai on the community.jboss.org forums helped me out. The solution is to add the JMS Queue as a dependency on the MDB. In my case I used the @Depends annotation:

@MessageDriven(activationConfig = {
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
        @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/MyQueue") })
@Depends("jboss.messaging.destination:service=Queue,name=MyQueue")
public class MyMessageListener implements MessageListener {
    ...
}

You could do the same using jboss.xml if you aren't using annotations.

like image 76
mluisbrown Avatar answered Sep 27 '22 18:09

mluisbrown