如何在JBoss 5中订购部署EJB和JMS队列配置? [英] How to order deployment of EJBs and JMS queue config in JBoss 5?

查看:110
本文介绍了如何在JBoss 5中订购部署EJB和JMS队列配置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JBoss [EAP] 5.0.0.GA,并且我有一个EAR,其中包含一个包含一些MDB的EJB jar,这些MDB依赖于它们使用的JMS队列的存在。当我在 ... / server / all / deploy / messaging / myqueues-service.xml 中配置队列时,没有问题。



但是,我想在EAR文件中配置队列,以避免直接对JBoss配置进行更改。没有问题,我把我的 myqueues-service.xml 文件放入EAR的根目录,并将引用添加到我的 jboss-app.xml 如下:

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

然而,当我这样做时,JBoss加载了EJB jar(包含在my-ear.ear中)然后先配置JMS队列。加载MDB时会导致错误:

  12:16:02,714 WARN [JmsActivation] jms激活失败org.jboss .resource.adapter.jms.inflow.JmsActivationSpec @ 13a59e ..... 
javax.naming.NameNotFoundException:MyQueue未绑定

这不是一个巨大的问题,因为MDBs的后续成功重新连接到JMS:

  12 :16:12,698 INFO [JmsActivation]尝试重新连接org.jboss.resource.adapter.jms.inflow.JmsActivationSpec@f91ad5 
12:16:12,823 INFO [JmsActivation]与消息传递提供程序重新连接。

但我真的很想避免出现任何错误,为了做到这一点,我需要一个在加载EJB jar之前,先强制JBoss配置JMS队列。有没有办法做到这一点?作为参考,以下是EAR的 application.xml

  ; application xmlns:xsi =http://www.w3.org/2001/XMLSchema-instancexmlns =http://java.sun.com/xml/ns/javaeexmlns:application =http:/ /java.sun.com/xml/ns/javaee/application_5.xsdxsi:schemaLocation =http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns /javaee/application_5.xsdversion =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>

任何建议赞赏。

解决方案

好的, jaikiran pai on community.jboss.org论坛帮助我。解决方案是将JMS队列作为依赖关系添加到MDB上。在我的情况下,我使用@Depends注释:

  @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实现MessageListener {
...
}

如果您不使用注释,您可以使用jboss.xml执行相同操作。


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.

解决方案

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.

这篇关于如何在JBoss 5中订购部署EJB和JMS队列配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆