【问题标题】:Deploy MDB using GenericJMSRA on GlassFish with annotations?使用带有注释的 GlassFish 上的 GenericJMSRA 部署 MDB?
【发布时间】:2013-04-17 08:50:05
【问题描述】:

在 GlassFish Server 2.1 上,我创建了一个用于与 ActiveMQ 连接的 GenericJMSRA,如本指南中所述:http://activemq.apache.org/sjsas-with-genericjmsra.html

我已经成功地使用 ejb-jar.xml 注入上下文的经典方式来部署 MDB:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN'     'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
<ejb-jar>
  <enterprise-beans>
    <message-driven>
      <ejb-name>QueueListener</ejb-name>
      <ejb-class>foo.QueueListenerMDB</ejb-class>
      <transaction-type>Container</transaction-type>
    </message-driven>
  </enterprise-beans>
</ejb-jar>

和 sun-ejb-jar.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Application Server 8.1 EJB 2.1//EN' 'http://www.sun.com/software/appserver/dtds/sun-ejb-jar_2_1-1.dtd'>
<sun-ejb-jar>
  <enterprise-beans>
    <ejb>
      <ejb-name>QueueListener</ejb-name>
        <mdb-connection-factory>
          <jndi-name>jms/amqQueueConnectionFactory</jndi-name>
        </mdb-connection-factory>
        <mdb-resource-adapter>
        <resource-adapter-mid>activemqra</resource-adapter-mid>
        <activation-config>
          <activation-config-property>
            <activation-config-property-name>DestinationType</activation-config-property-name>
            <activation-config-property-value>javax.jms.Queue</activation-config-property-value>
          </activation-config-property>
          <activation-config-property>
          <activation-config-property-name>destination</activation-config-property-name>
            <activation-config-property-value>qRequest</activation-config-property-value>
          </activation-config-property>
        </activation-config>
      </mdb-resource-adapter>
    </ejb>
  </enterprise-beans>
</sun-ejb-jar>

我将如何继续以注释驱动的 EJB 3.0 样式注入上述配置?更具体地说,我不知道如何注入以下属性:

<resource-adapter-mid>activemqra</resource-adapter-mid>

【问题讨论】:

    标签: java annotations message-driven-bean glassfish-2.x ejb-jar.xml


    【解决方案1】:

    终于搞定了。

    我完全删除了 ejb-jar.xml 并保持 sun-ejb-jar.xml 不变。然后我将类 foo.QueueListenerMDB 注释如下:

    @MessageDriven(name = "QueueListener", mappedName = "QueueListener")
    public class QueueListenerMDB implements MessageListener {
        ...
    }
    

    【讨论】:

      猜你喜欢
      • 2014-10-20
      • 2011-07-29
      • 2015-06-03
      • 2015-12-31
      • 1970-01-01
      • 1970-01-01
      • 2017-07-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多